Delete VMs in CSV

This post was originally published on this site

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:Windowssystem32> connect-viserver –server w.x.y.z



$vms = Import-Csv ‘C:UsersAdministratorDocumentslocaluserdeleteVM.csv’ -UseCulture



foreach($vm in $vms){

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


Any ideas ??

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.