VMware Cloud Community
SankyArora
Contributor
Contributor
Jump to solution

Remove-VM

I am running command "Remove-VM -VM (Get-VM) -DeleteFromDisk".

This command is deleting vm files but vm is seen as orphaned in vcenter server.

How to completely remove vm from vcenter server as well as from the disk.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

If you delete VM while connected to an ESXi server, there will be orphaned VMs in vCenter.

Why do you need to remove them on the ESXi server ?

With

Get-VM -Name MyVM | where {$_.Host.Name -eq "MyEsx"} | Remove-VM -DeletePermanently -Confir:$false

you can remove the VM completely, and the vCenter registration will be removed as well.

Your problem to connect to the ESXi with its IP address could have several reasons: port 902 is not open, the host is not reachable....

Are there any error messages ?


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Could it be that you are connected to an ESXi server and not to the vCenter (with the Connect-VIServer cmdlet) ?

The VM registration is done on the vCenter.


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

Reply
0 Kudos
SankyArora
Contributor
Contributor
Jump to solution

Thanks for reply. Smiley Happy

It works well if i pass "vcenter server ip" for -Server argument but doesnot work for if i pass "esx ip".

I want to delete vms of particular esx host.

Pls help me out

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you delete VM while connected to an ESXi server, there will be orphaned VMs in vCenter.

Why do you need to remove them on the ESXi server ?

With

Get-VM -Name MyVM | where {$_.Host.Name -eq "MyEsx"} | Remove-VM -DeletePermanently -Confir:$false

you can remove the VM completely, and the vCenter registration will be removed as well.

Your problem to connect to the ESXi with its IP address could have several reasons: port 902 is not open, the host is not reachable....

Are there any error messages ?


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

Reply
0 Kudos
SankyArora
Contributor
Contributor
Jump to solution

Thanks!!! It works...

Reply
0 Kudos