Problem solve Get help with specific problems with your technologies, process and projects.

Fun with PowerShell & VMware

Can we automate the adding of an ESX host to VirtualCenter – and can we script the changing of the port group assignment of virtual machines?

I’ve been playing with the new powershell kit from VMware which is currently in Beta. It’s pretty cool, and helps...

to address some of the common automation requests which my students and customers come up with. For example: can we automate the adding of an ESX host to VirtualCenter – and can we script the changing of the port group assignment of virtual machines?

I haven’t been playing long with Powershell – a day or so. But I’m impressed enough to, at some point soon, put together quickly a “Getting Started Guide”" so you can join in the fun. For the moment here are some links you will find REALLY useful.

Firstly, if you are running VirtualCenter on Windows 2003 – you will need to download the PowerShell 1.0 package from Microsoft. There is an XP & Vista version too – but I choose to install my powershell stuff to my VirtualCenter box:

Secondly, here’s where you find the release notes on the VMware PowerShell Toolkit Beta, it is also where you will find the download.  Thirdly, here’s a really handy tool from PowerGUI.org. This puts a graphical shell around the command-line such that you ask for tasks to happen through a graphic front-end – and it greets the powershell scripts for you. This is absolutely fantastic – and means if you're an admin like me you don't need to learn directly how to type in strings of powershell code

http://www.powergui.org/downloads.jspa

Fourthly, you will also need from Quest a free extender of PowerShell that makes it easy to authenticate against an Active Directory system

https://www.quest.com/powershell/activeroles-server.aspx

Finally, another set of people have written an extension called the VMware VIT Kit.powerpack to PowerGUI that adds a whole series of tasks you can carry out – again all you have to do is import this powerpack to PowerGUI – to get the GUI front-end – and they do all code for you

http://powergui.org/entry!default.jspa?categoryID=21&externalID=1802

After installing these 1-2MB applications – within about 5mins I had script that changed the power groups on a few of my virtualmachines:

Get-VM -Server $global:VIServer | Sort-Object -property “Name” | where { ‘web-1′, ‘sql-1′, ‘fs-1′, ‘dc-1′, ‘ctx-1′ -contains $_.Name} | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName vlan23

Did I have to learn all this code and syntax – no PowerGUI+

This was last published in June 2008

Dig Deeper on VMware Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close