Skip to content

Instantly share code, notes, and snippets.

@sammcgeown
Created March 24, 2020 14:15
Show Gist options
  • Save sammcgeown/ff1d43559b3dce8d721adee3930d6925 to your computer and use it in GitHub Desktop.
Save sammcgeown/ff1d43559b3dce8d721adee3930d6925 to your computer and use it in GitHub Desktop.
PowerShell ABX Rename Machine
function handler($context, $payload) {
$oldVMName = $payload.resourceNames[0]
$newVMName = $payload.customProperties.userDefinedName
$returnObj = [PSCustomObject]@{
resourceNames = $payload.resourceNames
}
$returnObj.resourceNames[0] = $newVMName
Write-Host "Setting machine name from $($oldVMName) to $($newVMName)"
return $returnObj
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment