VMware Cloud Community
HatemShams
Contributor
Contributor

Delete VMs in CSV

Hi Folks,

I just faced a weird problem that I can't explain till now. I have two vCenter which I replicate some VMs from Source vCenter to Destination vCenter.

I ran the hereunder script to shutdown a bunch of VMs listed in CSV file (deleteVM.csv). Those VMs are located in a vCenter w.x.y.z . The command ran successfully, but a few minutes later my customer reported that those VMs are force shutdown from the Destination vCenter as well.

PS C:\Windows\system32> connect-viserver –server w.x.y.z

$vms = Import-Csv 'C:\Users\Administrator\Documents\localuser\deleteVM.csv' -UseCulture

foreach($vm in $vms){

  Get-VM $($vm.oldname) | Shutdown-VMGuest -confirm:$false}

Any ideas ??

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Are these vCenters running in Linked Mode?

Do you have by accident more than 1 connection open?

What is in $global:defaultVIServers?


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

Reply
0 Kudos