Saturday, May 10, 2014

VMware: Create new port group via PowerCLI

If you want to create a standard vswitch portgroup on all hosts in a cluster, this script is for you!

This script will connect to your vcenter, and iterate through every host in the cluster.  Just make sure to set the parameters highlighted in yellow correctly.

connect-viserver VCENTER

$Cluster = "Cluster01"
$vSwitch = "vSwitch0"
$NPG = "PORT-GROUP-NAME"
$VLAN = "VLAN-NUMBER"
Get-Cluster -Name $Cluster | Get-VMHost | foreach { New-VirtualPortGroup -VirtualSwitch ( Get-VirtualSwitch -Name $vSwitch -VMHost $_ ) -Name $NPG -VLanId $vlan }

No comments:

Post a Comment

Featured Post

Remove 3D Objects and other annoying folders on Windows 10

 Microsoft just keeps adding more crap to clutter up the navigation in Windows 10.  Seriously, who needs a 3D Objects folder?  The tiny perc...