Hi all,
I need to remove hosts from inventory and am unable to. I'm stuck removing them from the vSwitch.
I generate an array of hosts like this:
$HOSTS = get-vmhost | Where-Object {($_.Name -like '*26*') -or ($_.Name -like '*27*') -or ($_.Name -like '*28*') -or ($_.Name -like '*29*') -or ($_.Name -like '*43*')}
But I'm unable to figure out how to remove them from the distributed switch and then from inventory.
Any help would be appreciated.
-Chris
Is there a VMKernel or a Portgroup on that switch that is used by that ESXi node?
You will have to migrate those first.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you try the Remove-VDSwitchVMHost cmdlet?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
I'm not sure what the problem is, but that cmdlet does not exist for me:
Remove-VDSwitchHost Remove-VDSwitchHost: The term 'Remove-VDSwitchHost' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
pwsh > $PSVersionTable
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEAS…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Thanks!
-Chris
That is Remove-VDSwitchVMHost
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for that (doh!).
The cmdlet ran but failed to remove the VMhost from the vSwitch (vCenter is version 6):
get-vdswitch -Name dvSwitch1 | Remove-VDSwitchVMHost -VMHost sfo-engesx26
Confirm
Are you sure you want to perform this action?
Performing the operation "Removing VMHost(s) 'sfo-engesx26'" on target "dvSwitch1".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Yes"): y
remove-vmhost -VMhost sfo-engesx26
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-VMHost" on target "VMHost 'sfo-engesx26'".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Yes"): y
Remove-VMHost: 2/2/2021 9:55:25 AM Remove-VMHost The operation for the entity "sfo-engesx26" failed with the following message: "The resource 'sfo-engesx26' is in use.". Cannot remove the host sfo-engesx26.eng.dolby.net because it's part of VDS dvSwitch1
Is there a VMKernel or a Portgroup on that switch that is used by that ESXi node?
You will have to migrate those first.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc!
You are awesome and your help is really appreciated!!
-Chris