Skip to content

Instantly share code, notes, and snippets.

@chelnak
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save chelnak/f6ebaaec479b68c5f7b8 to your computer and use it in GitHub Desktop.

Select an option

Save chelnak/f6ebaaec479b68c5f7b8 to your computer and use it in GitHub Desktop.
Migrate vRealize Machine Prefixes with PowerShell
#full path to cloudclient
$cloudClientPath = "D:\cloudclient\bin\cloudclient.bat"
#Path to your prefix json file
$prefixJsonFile = "vra-machineprefixes.json"
#Path to the resulting script file
$prefixScriptFile = "machineprefix-cloudclient-commands.ps1"
$machinePrefixes = Get-Content -Raw -Path "$($prefixJsonFile)" | ConvertFrom-Json
$outFile = @()
foreach ($item in $machinePrefixes.Items){
$outFile += "Invoke-Expression -Command '$cloudClientPath vra machineprefix add --prefix $($item.Prefix) --nextNumber $($item.NextNumber) --numberOfDigits $($item.NumberOfDigits)'"
}
$outFile | Set-Content -Path "$($prefixScriptFile)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment