Dec
24
2008

Creating portgroups with PowerShell

I must  be a workaholic. I was browsing my laptop for some movie and I came across a folder with all kinds of plugins for VirtualCenter. Things like addPortgroup and other stuff.

Although it’s very handy to use those plugins I like to be able to these kind of things from the commandline, so I started some PowerShell script (here is where the workaholic starts) to create portgroups on all your VMware hosts that are known by VirtualCenter.

I wanted to make it a oneliner, but that was too much. My PowerShell scripting powers aren’t that good that I can get it to work :)

So here it is with a couple of lines. It creates a portgroup on vSwitch0 with PG as name and VLAN 99. Ofcourse it only works if you use the VI Toolkit from VMware.


foreach ($vmhost in get-vmhost)
{
new-VirtualPortGroup -name PG -VirtualSwitch (Get-virtualswitch -VMHost $vmHost -name vSwitch0) -VLAN 99
}

Happy holidays again :)


Related posts:

  1. Searching for a VM
  2. More PowerShell stuff
  3. VMware and PowerShell
  4. Managing VMware with PowerShell FAQ
  5. Managing Remote ESX Hosts Over WAN with VirtualCenter
Written by Anne Jan Elsinga in: Networking, PowerShell, VMware, vCenter/VirtualCenter | Tags: ,
In real live MeAgain is Anne Jan Elsinga. He's a Technical Consultant for Centric Managed ICT Services in the Netherlands. He spends his working hours with a lot of virtualization stuff, from feasibility to implementation for server virtualization/consolidation and desktop virtualization. In the night time he dances latin, ballroom and salsa and he recently discovered the pleasure of diving.
blog comments powered by Disqus

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes