Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 252940

Re: remove-vm doesn't delete from inventory

$
0
0

I see. It looks as if you have these VMs with the same name in different datacenters.

You can also use a Get-Datacenter -Name <dcname> on the Location parameter of the Get-VM.

That way only that specific VM gets removed (and unregistered).

Something like this

 

$vmlist= ("vm1","vm-2","vm-3")$dcName="MyDC"
foreach
($vmnamein$vmlist) {  $vm=GET-VM-Name$vmname-Location (Get-Datacenter-Name$dcNameif($vm.PowerState-ne"PoweredOff")  {    Stop-VM-VM$vm
   
Write-output"$vmname shutting down" (get-date)  }  Remove-VM$vm-DeleteFromDisk:$true
}

Viewing all articles
Browse latest Browse all 252940

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>