Script
-----------------------------------------------------------------------------------------
#Remove all port groups on speific vSwitch#
Add-PSSnapin vmWARE.VimAutomation.Core
Connect-VIServer VCName
$hostserver = "10.194.194.80"
$virtualsw = Get-virtualswitch -vmhost $hostserver -Name vSwitch0
#$vswgoup = Get-VirtualPortGroup -VMHost 10.194.96.1 -VirtualSwitch $virtualsw | where { $_.Name -ne "Management Network" }
$vswgoup = Get-VirtualPortGroup -VirtualSwitch $virtualsw | where { $_.Name -ne "Management Network" }
$vswgoup | Remove-VirtualPortGroup -confirm:$false
Disconnect-VIServer VCName
时间: 2024-08-16 05:51:12