VMware Cloud Community
allanclark
Contributor
Contributor

Using Remove-VM

I am trrying to run a scheduled job to delete a cloned VM.

Every time I run Get-VM <..........VM Name...........> | remove-vm -deletefromdisk -confirm:$false

But the VM goes Orphaned - files are deleted from the disks.

also tried 

Get-VM <.....VM Name...........> | Remove-VM -DeletePermanently -Confirm:$false

gives same results.

Tags (1)
0 Kudos
3 Replies
LucD
Leadership
Leadership

That must mean you are connected to the ESXi server and not the vCenter.

You could check/display the contents of the $global:defaultviservers variable to verify.


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

0 Kudos
allanclark
Contributor
Contributor

Yes logged onto ESXi rather than vCentre, with root credentials.

So take it needs to be a connect-viserver to vCentre?

0 Kudos
Sreejesh_D
Virtuoso
Virtuoso

yes, to get it cleaned from the vCenter DB we've to connect to the vCenter and perform delete.

0 Kudos