VMware Cloud Community
vmk2014
Expert
Expert

BULK UNREGISTER / REGISTER VMS ON VSPHERE 6.0

Hi All,

I want to perform bulk removal/unregister of VM's from source environment vsphere host 6.0 and Register/add that VM's to the swing host ESXi 7.0. for migration purpose.Steps will like

1) Shut down all the VM's gracefully from C:\temp\VMliste

2) Remove VM's from inventory or unregister from source environment i.e. ESXi 6.0 and Register/add that VM's to the swing host ESXi 7.0. for migration purpose. C:\temp\vmliste ( For unregister and registering)

is it possible from power cli to perform this task to reduce the downtime ? Any help will appreciated.

 

Thanks

Vmk

Labels (1)
Reply
0 Kudos
2 Replies
scott28tt
VMware Employee
VMware Employee

@vmk2014 

Have you searched this area for examples of code for the 3 steps you wish to carry out?

1. Shutdown

2. Unregister

3. Register

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
vmk2014
Expert
Expert

Thanks Scott,

I can perform first step 1  i.e. shutdown bulks VM's using the script

# Part 1

$vmNames = Get-Content -Path .\vmnames.txt

$vms = Get-VM -Name $vmNames |

where{$_.PowerState -eq 'PoweredOn'}

Shutdown-VMGuest -VM $vms -Confirm:$false

while((Get-VM -Name $vmNames).PowerState -contains 'PoweredOn'){

sleep 5

}

$vms | Select Name | Export-Csv -Path .\vm-powered-off.csv -NoTypeInformation -UseCulture

Part 2 

https://www.miru.ch/bulk-unregister-register-vms-on-vsphere

But i'm looking for specific list of VM's spread across the cluster

# Part 4

 

$vmNames = Import-Csv -Path .\vm-powered-off.csv -UseCulture

 

Get-VM -Name $vmNames.Name |

Start-VM -Confirm:$false

Reply
0 Kudos