You can tell I’m getting rusty with the PowerCLI, which is something I intend to fix. In the meantime, I needed a PowerCLI way to remove all vmnics from a host’s vSS. If you take a look at the PowerCLI cmdlet documentation, you’ll find the syntax for Set-VirtualSwitch. It’s pretty simple; whatever NIC you pass along with the -Nic parameter overwrites whatever’s there already.
Get-VirtualSwitch -VMhost host1.lab.local -Name vSwitch1 | Set-VirtualSwitch -Nic vmnic4
The above code will replace whatever vmnics are currently connected to the vSwitch with vmnic4. But what if you want to remove all the nics from the vSwitch? The answer is simple; pass an empty array to the -Nic parameter.
$nic = @() //creates an empty array called $nic
Get-VirtualSwitch -VMhost host1.lab.local -Name vSwitch1 | Set-VirtualSwitch -Nic $nic
[…] via PowerCLI: Remove all vmnics from a vSwitch — DAMIAN KARLSON. […]