Home > Blogs > VMware PowerCLI Blog


Automation and TechEd 2008

If you’re like me you get bored with clicking through Wizard interfaces after about the 5th time or so. On the other hand scripting is a lot more powerful, but at the same time requires you to learn programming languages and APIs, not exactly a lot of fun. Whenever I’m staring at a 12-step wizard I always wish there was a way I could convert it to a spreadsheet input view that would let me fill in a bunch of them at once and then automatically run through everything for me. That’s the motivation for this spreadsheet . Basically it lets you enter an entire table of values, but takes care of all the scripting for you. Using the spreadsheet is very simple, but as always you will need to havei nstalled the VI Toolkit (for Windows) on your computer.

Here’s a video of me putting it to the test:


Creating lots of VMs, best viewed fullscreen.

The script is actually pretty simple, if you want to see it for yourself it’s hidden in cell A2 of the spreadsheet, or you can see it here.

foreach ($f in (import-csv "parameters.csv")) {
if ($f."Host Name") {
  $vmhost = get-vmhost $f."Host Name"
} else {
  $vmhost = get-vmhost
}
if ($f."Resource Pool") {
  new-vm -host $vmhost -name $f.Name -diskmb ([long]$f."Disk Size (GB)" * 1024) -memorymb \
   $f.Memory -networkname $f."Network Name" -resourcepool \
   (get-resourcepool $f."Resource Pool") -runasync
} else {
  new-vm -host $vmhost -name $f.Name -diskmb ([long]$f."Disk Size (GB)" * 1024) -memorymb \
   $f.Memory -networkname $f."Network Name" -runasync
}
}

Not bad for 15 lines of PowerShell.

If you’re feeling a bit adventurous you could easily modify the script to accept different values, or to perform different actions.

We’ll have this demo and many others, including cloning VMs and creating virtual switches, available for you to play with in real-time at our booth at TechEd. And stay tuned, I’m going to be giving a few more previews of the PowerShell power tools we’re going to have to play around. Hope to see you all there.

One thought on “Automation and TechEd 2008

Leave a Reply

Your email address will not be published. Required fields are marked *

*