VMware Cloud Community
Vphilliycheese
Contributor
Contributor
Jump to solution

Trying to append a VMs display name with “_AzureMigrated” after it has been migrated to Azure

Hello community friends!

I am trying to work a process into a migration project that I am working on. Basically I am migrating some VMs from on-prem vCenter to Azure and once they are migrated I need to append “_AzureMigrated”  to the VM's display name in vCenter. I found this script but thought I should run it by the community. 

 

# Connect to vCenter Server
Connect-VIServer -Server vCenterServer

# Get the virtual machine object
$vm = Get-VM -Name "VMName"

# Append "_AzureMigrated" to the display name
$vm.ExtensionData.Config.Name += "_AzureMigrated"

# Update the virtual machine
$vm | Set-VM

# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Afaik that is not how a rename of the Display name works.
Try something like this

$vmName = 'VMName'
# Connect to vCenter Server
Connect-VIServer -Server vCenterServer

# CHange the VM's Display name
Get-VM -Name $vmName | Set-VM -Name "$vmName_AzureMigrated" -COnfirm:$false

# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik that is not how a rename of the Display name works.
Try something like this

$vmName = 'VMName'
# Connect to vCenter Server
Connect-VIServer -Server vCenterServer

# CHange the VM's Display name
Get-VM -Name $vmName | Set-VM -Name "$vmName_AzureMigrated" -COnfirm:$false

# Disconnect from vCenter Server
Disconnect-VIServer -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Vphilliycheese
Contributor
Contributor
Jump to solution

Thanks @LucD can always count on you 🙂 

Reply
0 Kudos