To remove a host from your vCenter Server inventory, you have to use the Remove-VMHost
cmdlet. The Remove-VMHost
cmdlet has the following syntax:
Remove-VMHost [-VMHost] <VMHost[]> [-Server <VIServer[]>]
[-WhatIf] [-Confirm] [<CommonParameters>]
Let's try to remove a host, as seen in the following screenshot:
.
The operation failed because the host must be in maintenance mode or disconnected state before you can remove it, as you can see in the following screenshot from the vSphere Web Client:
So, let's put the host in maintenance mode first and then try to remove it:
PowerCLI C:\> $VMHost = Get-VMHost -Name 192.168.0.133 PowerCLI C:\> $VMHost | Set-VMHost -State Maintenance Name ConnectionState PowerState NumCpu CpuUsageMhz ---- --------------- ---------- ------ ----------- 192.168.0.133 Maintenance PoweredOn 2 41 PowerCLI...