ADVERTISE HERE

PowerCLI: Two Virtual Switch and Portgroup one-liners

Title: PowerCLI: Two Virtual Switch and Portgroup one-liners
Author(s): (ICT-Freak.nl) Arne Fokkema
Target Audience: Technical - Intermediate
Current Revision:
First Published: 7 December 2009
Products: PowerCLI
UID: XD10153

Powershell one-liners to do some maintenance on Virtual Switches and PortGroups

Punchy Text: 

Powershell one-liners to do some maintenance on Virtual Switches and PortGroups

By Arne Fokkema - ICT-Freak.nl


PowerCLI

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:

vSphere PowerCLI

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

vSwitch0 Properties

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:

vSphere PowerCLI 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 }

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

Technology Exchange: