VMware: Add PortGroup to all hosts in cluster with PowerCLI
Today we configured a new VLAN on the physical switches, now we need to configure a portgroup with vlan id on multiple ESX hosts in our cluster. To do this by hand it will cost 3 minutes per host, to script this.. you configure this in 10 seconds!
The script:
Get-Cluster “clustername” | Get-VMHost | Get-VirtualSwitch -Name “vSwitch0” | New-VirtualPortGroup -Name “VLAN-23-Citrix Provisioning” -VLanId 23
Voila!
Nice oneliner, always handy
Great
Excellent, this is not a default policy isnt it?
Thank you – saved me a lot of work. Maybe I should have spend some more time looking into scripts than add VLANs mindlessly π
Thank you.
It is realy helpfull.
Just started in VMware scripting and this is a great one-liner! Thanks for sharing π
Thank you, you’re still helping someone….. π
Hi
it doesn’t work for me.
after I apply command i get prompt like that: “>>”.
nothing executes.
ok, i know.
I had to write vSwitch0 without quotation marks.
Thanks =0)
REALLY nice! Thank you for sharing.
Thanks. It saves a lot of time.
thanks, its saved my time.
Hi,
Can anyone tell me how to add multiple vlan/port groups to one esxi host using csv. Please share me the csv format and script.