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

Monthly Archives: June 2008

Making peace between VirtualCenter and Lab Manager

If you’re a VMware Lab Manager user, you may have encountered a strange-sounding recommendation that you shouldn’t manage an ESX system with both Lab Manager and VirtualCenter. One reason stems from the fact that if you delete a VM directly from an ESX server, VirtualCenter will actually display the VM as "orphaned". If you use Lab Manager extensively you’re going to be creating and deleting a lot of VMs, and since Lab Manager manages ESX directly, this leads to lots of orphaned VMs, which can quickly become a usability issue.

Justin Grote has written a script that he uses to deal with this problem. Justin makes peace between the two by figuratively sending the two products to their respective rooms: all Lab Manager VMs are kept in their own folder and resource pool, which also makes it easy to identify an orphaned Lab Manager VM when it comes time to remove it later on. It’s a great example of how a tool like the VI Toolkit (for Windows) can make your life easier, whether it’s by filling in some of the blanks left in VMware’s products, or just coping with stuff that maybe shouldn’t be that hard to begin with.

Great work, Justin!

Fun with PowerShell 2.0 modules: Storage VMotion

One of the most exciting new features coming in PowerShell 2.0 is the addition of PowerShell modules. When you use modules you don’t have to install or register software. I think the most exciting aspect of this is the fact that you deliver functionality purely over the internet without the need to install and update software on client systems.

That’s the idea we have in mind when we decided to publish the VMware PowerShell Community Extensions. Currently the name is a bit more advanced than the idea, since it’s really only 3 cmdlets at the moment, but I personally hope that this will grow into a means for us to deliver functionality quickly and effectively, get feedback in a timely manner, and ultimately make for a much better product. To use the extensions, you’ll need the latest version of the PowerShell 2 CTP, and, of course, the VI Toolkit (for Windows).

Loading the extensions into your session is as simple as these two lines of code:

This code is kind of silly if you think about it, all this really does is download the module from vmware.com to your temp directory and then add it. It would be nicer if you could do something like add-module \\vmware.com\PowerShellExtensions\Extensions.psm1, but we’re not there yet. Also, a bit of full disclosure, this version of the extensions is not signed, yet add-module doesn’t seem to have a problem with it even if your PowerShell execution policy is RemoteSigned. This is likely a bug in the PowerShell 2 CTP. The editing of the module is very restricted (in fact, it’s restricted to just me at the moment,) but if you’re feeling paranoid, you should download the module, examine it to make sure everything looks ok, and only then add it.

One of the cmdlets in the first round of the extensions is SVMotion-VM, which is short for "Storage VMotion a VM". If you don’t know what that means, trust me you’re far from alone. Basically Storage VMotion allows you to move all the files that represent a Virtual Machine from one storage array to another, even if the VM is up and running. This is really useful if you find yourself running low on storage on one array but have plenty on another, or if you buy a fancy new storage array and want to move everything off of your old gear.

The trouble with moving lots of bits around, of course, is that it takes forever. That just means that this is the perfect sort of thing to script. Below is a video that shows exactly that:

Unfortunately the video was a bit too wide for the screen, so for now you’ll just have to settle for this: Video of Storage VMotion through PowerShell

As promised in the video:

There’s a somewhat tricky bit of code in the video that I use to analyze my datastores.

Basically this is just taking advantage of the select cmdlet’s ability to run code blocks to analyze objects in more depth. This is a pretty nice bit of code to see how much data is in use from VMs and where it lives, and also mixes nicely with the export-csv cmdlet for further analysis in Excel. Here is the sample output I made in the video:


Back to the Community Extensions for a moment.

You may be wondering what to expect from the community extensions. Of course, part of it depends on your feedback, but here’s how I think it will work: The VI Toolkit (for Windows) will contain cmdlets that are well-tested, documented, supported, etc. The community extensions will contain cmdlets that may have little or no testing, may have limited usability in their parameter sets, and likely no documentation or examples. The most useful community extensions will eventually become full, official cmdlets, with all the testing and documentation that comes with it.

Let us know.

Your feedback on this is greatly appreciated, and that includes anything from suggestions about our approach to requests for new cmdlets.

Also, don’t forget that PowerShell 2.0 modules will be just one of many things discussed at tomorrow’s PowerShell Virtual User Group.

VMware and PowerShell at the next PowerShell Virtual User Group

Marco Shaw has announced the 6th Windows PowerShell Virtual User Group Meeting will be held on 6/24/2008 at 8:00 P.M. Eastern time, and there will be a terrific group of speakers present.

The group includes Bruce Payette (of PowerShell in Action fame), Wassim Fayed (master of PowerShell remoting) and Hal Rottenberg (author of an upcoming book that will be the definitive guide to managing VMware with PowerShell.)

In addition to VMware management, the session will also cover PowerShell modules and PowerShell remoting, two of the most important features coming in PowerShell version 2. Don’t miss it!

Congratulations, PowerGUI!

Congratulations to Dmitry Sotnikov and the PowerGUI team from Quest Software for winning the "Best of TechEd Breakthrough Product" award at TechEd last week! Being a PowerGUI user myself I can tell you it’s a great tool, especially if you get nervous around a command line.

Coincidentally, Mike Laverick over at RTFM Education has written an excellent whitepaper that details managing VMware with PowerGUI and the VI Toolkit (for Windows). The whitepaper covers everything from installation of all the tools you need to the actual details of managing your VMs. I’m really looking forward to seeing how managing VMware from PowerGUI will get better and better over time.

Virtual switches are hard.

Jonathan Walz and Hal Rottenberg have an excellent podcast that is devoted to Windows PowerShell, if you haven’t listened you should definitely give it a try.

In their most recent episode, Hal mentioned that I will be at TechEd in Orlando next week. Hal also mentioned that I had some demos that I would be running, which is not quite true. Actually you’re going to be running the demos yourselves. If you come visit us at the VMware booth next week, you get to enter the values you want into any of the spreadsheets I’ve been publishing so far, press GO! and watch the magic happen.

So if you’ve ever wanted to create 500 VMs at once across multiple hosts, here’s your chance. The best part is that you have all the fun and we clean up all the mess.

Which brings me to my next spreadsheet. Not only do I show off my automation prowess, but I will also surely impress you with my sense of color co-ordination. This time we’re creating lots of virtual switches at a time. When I was at VMworld Europe earlier this year, I was surprised at the number of people who came up to me complaining about how tedious it is to set up virtual switches. Throw in a number of VM networks per switch and a VMkernel or two and you’ve got a lot of clicking to look forward to. This is exactly the problem VMware is trying to solve with our PowerShell cmdlets.

Creating Virtual Switches In Style:


Unfortunately I don’t have a video this week, so a brief description of how to use the spreadsheet is in order. First, the approach I take is that you create all your virtual switches at once, then all your VM networks, then all of your VMkernels.

When you create virtual switches you can configure all advanced functionality like NIC teaming and beacon probing when you create it. If you don’t need all of this stuff, you can confine yourself to the first section of the "Virtual Switches" tab, but it’s still worthwhile to see what capabilities are there in the other sections. Overriding these advanced options within VM Networks is not supported in this spreadsheet. If you read this paragraph and wondered if I had suddenly started speaking in tongues, you can learn more about advanced networking in VMware’s Virtual Networking Concepts guide.

If you take a look at the code used by this spreadsheet (hidden, as always, in cell A2), you may notice that the code is quite complex, not much like the simple scripts you may be used to. This is because the VI Toolkit (for Windows) doesn’t yet have all of the advanced functionality I need to make this spreadsheet work. Instead, I resorted to using our web services directly. The goal of the Toolkit is to gradually make hard things easy and of course we try to focus on the most important things first. Of course we don’t know what is most important without your feedback, so let us know. Do you use advanced features like NIC teaming? Policy overrides within port groups or VMkernels? Other advanced features? Let us know, on the blog or within our forums. (And don’t forget to drop by for a chat next week at TechEd, see you there.)