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)"