PowerCLI: Two Virtual Switch and Portgroup one-liners
By Arne Fokkema - ICT-Freak.nl

In this post you’ll find two Powershell one-liners to do some maintenance on Virtual Switches and PortGroups.
The first one-liner is inspired by Hany Michel his post: vMotion vs. VMotion .. Vote for your favourite! In this post he starts the debate about which name it should be. I voted for the “new” name vMotion. If you want to change the name of the VMotion portgroups to the “new” standard. You can do this by hand but why, we got PowerCLI. The following one-liner will do the job:
| Get-VMhost | % { Get-VirtualPortGroup -VMhost $_ -Name VMotion ` | Set-VirtualPortGroup -Name vMotion -Confirm:$false } |
The vSwitches with the VMotion Portgroup name will be changed to vMotion:

The next one-liner will change the number of ports on vSwitch0. The default setting on vSwitch0 is 24 ports.

With PowerCLI you can easily change this again with a one-liner. This one-liner will change the value to 120 ports:
| Get-VMHost | % {Get-VirtualSwitch -VMHost $_ -Name vSwitch0 | ` where {$_.NumPorts -lt "128"}} | ` % { Set-VirtualSwitch -VirtualSwitch $_ -NumPorts "128" } |
You’ll see the following output:

You need to reboot the ESX host to apply the new setting.
Get-VMhost | % { Get-VirtualPortGroup -VMhost $_ -Name VMotion `
| Set-VirtualPortGroup -Name vMotion -Confirm:$false }
- xtravirt's blog
- Login or register to post comments
Spotlight:
VMware Documentation Downloader v11.08.30
Updated for vSphere 5 - A free tool for those on the move who need information FAST
vSphere 5 License Entitlement Changes
See what has changed in the license entitlement in vSphere 5?
Thin Client vs Zero Client
The differences between Thin and Zero desktop clients for VDI
