Home > Blogs > VMware PowerCLI Blog > Monthly Archives: August 2008

Monthly Archives: August 2008

VI Toolkit contest: Just two days remain!

If you’re planning to enter our scripting contest for a chance to win a trip to VMworld 2008 or up to $5,000, you’d better hurry. The contest ends in just a bit over 2 days. To join all you have to do is register and upload your script to our forum. Good luck!

Don’t forget the PowerShell scripting contest! Win a trip to VMworld or $5000!

Entries are starting to roll in for our PowerShell scripting contest. You can see the entries in our community (you will need to register using the contest landing page above to see the community). We’re up to 8 submissions so far, so the field is starting to take shape. Don’t forget that the contest ends August 30th, just a bit over two weeks away. If you haven’t started you should download the toolkit and get started right away.

Just a reminder of the prizes:

  1. First Prize: Airfare, hotel and admission to VMworld 2008 Las Vegas (up to $5,000 in value) or $5,000 USD Cash Prize.
  2. Second Prize: Macbook Air with VMware Fusion or $2,500 USD.
  3. Third Prize is you’re fired. No actually, third prize is an Xbox 360 Elite or $500 USD.

Good luck to everyone!

Update: Looks like Eric Sloof and I had the same idea at the same time, but one more thing that I should mention is that we’ve also managed to get none other than PowerShell masters Lee Holmes and Bruce Payette from Microsoft to help with our judging. Thanks a million guys!

Managing VMware with PowerShell webinar.

Last week I gave a webinar on managing VMware with PowerShell. If you missed it or didn’t know about it, you can view it now. The webinar is mostly geared at people who haven’t used the toolkit at all, but has a few real-time demos of some of the really powerful stuff you can do with it. Even if a basic overview doesn’t sound all that interesting, the demos had a few examples you might not have known about, such as the example that shows how to set up VMotion. For the examples, please refer to the corrected slides I posted to slideshare.

There was also a Q and A session, which I’ve attached here with answers to the questions.


Improved Host Import

A few months ago I uploaded a little demo that let you import hosts into VirtualCenter using a spreadsheet. Well if there’s one constant in software it’s feature requests. A reader mentioned to me that this would be a lot more useful if he could import hosts directly into resource pools, clusters and things like that. Since it’s pretty easy to do in PowerShell (less than 50 lines in total) I updated the spreadsheet in hopes that other people could get some use out of this.

Here’s a preview of what it looks like:


One shortcoming of the spreadsheet is that if the host belonged to some other VirtualCenter, it will exist in that VirtualCenter as a disconnected host. It’s fairly easy to get rid of these though, if you connect to the old VirtualCenter using the VI Toolkit, then run

Get-VMHost | where { $_.State -eq "Disconnected" } | Remove-VMHost -confirm:$false

they will all be removed. Enjoy!


Keeping it simple with object-by-name.

I wanted to mention a really nice new feature of our 1.0 toolkit that greatly simplifies using it versus the Beta release. At the same time I want to introduce Andrey Anastasov, the toolkit’s architect and the guy who is perhaps most responsible for all the time saving goodness the toolkit brings to VI administrators.

As people began to experiment with the Toolkit over the past 8 months or so, one question kept coming up again and again. You can basically boil it down to "why do I have to use all these funny parentheses everywhere even when I want to do something as simple as create a VM?" As an example of what I mean, consider this:

new-vm -vmhost (get-vmhost myhost) -name myname

The syntax doesn’t look natural and is confusing when you sit down in front of the Toolkit for the first time. This can create a bad first impression, after all if you can’t figure out how to do something as simple as creating a VM, you’d probably guess that doing hard stuff would be next to impossible.We knew we had a usability problem that we had to fix. I think the team has done an excellent job solving the problem using what we call "Object By Name".

In fact, our PowerShell architect, Andrey Anastasov, has this to say about it:

"For its Beta, VI Toolkit implemented the get-then-modify usage pattern. Examples include Get-VM "My VM" | Start VM and Start-VM (Get-VM "My VM"). While constituting the very backbone of PowerShell, this pattern isn’t always convenient. And, as VMworld user feedback revealed, it’s not intuitive at all. So, for version 1.0 we added what we call object-by-name. It’s essentially shorthand which allows specifying an object’s name where an object is expected. For example, the old:

New-VM -vmHost (Get-VMHost "My Host") -name "My new VM"

can now be conveniently rewritten as

New-VM -vmHost "My Host" -name "My new VM"

Wildcards are there if you need them:

Start-VM "Web*"

Intuitiveness is just one of object-by-name’s virtues. A more practical example makes it evident that it also saves tons of typing, not to mention the wonders it works for readability:

New-VM -vmHost (Get-VMHost "My Host") -datastore (Get-Datastore "My Datastore") -network (Get-Network "My Network")


New-VM -vmHost ‘My Host’-datastore "My Datastore" -network "My Network"

So, it’s neat, intuitive, and convenient. What else is there to add? Well, it follows the bliss principle – what you don’t know about won’t hurt you. Actually, object-by-name is so unobtrusive you can easily miss it if you don’t know it’s there. The unobtrusive characteristic was one of our design goals. While we finally settled for a design which just quietly accepts names in place of objects, it wasn’t the only option we looked at. As an alternative, we considered adding extra parameter sets, the way a cmdlet like Stop-Process does it. But when you think about it, multiplying parameter sets and documentation isn’t a price you’re ready to pay when your objective is simplicity.

Looking back, the greatest challenge the team faced with object-by-name was in determining where to search for objects in multi-server scenarios. We found that if a cmdlet is invoked with a mix of object names and objects from different servers, there’s no universal strategy that’s both useful and intuitive. So we finally settled for limiting the ability to mix objects from multiple servers with object-by-name. This way, we’re leaving the door open for a future extension. Users already helped us a lot by producing the idea for object-by-name. Let’s see what they have to say about its implementation and possible enhancements."

Why is simplicity so important?

Have you ever felt like it would be quicker to do it yourself than to explain how to do it to someone else? That’s not necessarily a bad thing. A lot of times when a problem comes up that’s too hard for the sysadmin to solve, the problem gets turned over to a solutions team, who are experts at things like automation and integration. This sounds good in theory, but in practice it’s extremely hard to transfer knowledge from one head to another, and this can lead to a long and frustrating cycle of getting the problem almost solved. The way we look at it, a tool that 95% of people can use to solve their most urgent problems is better than a tool that 5% of people can use to solve every problem imaginable.

P.S. If you’re going to be at VMworld this year, be sure to stop by and say hi to Andrey and me, either at our session, or at the PowerShell demo area, hope to see you there.