Home > Blogs > VMware PowerCLI Blog > Monthly Archives: October 2007

Monthly Archives: October 2007

PowerShell GUIs

The PowerShell community has quite a few UI-driven or UI-friendly tools that work nicely with custom scripts. Examples include PowerGUI, PowerGadgets and Workflow Studio.

In that spirit, I sometimes want an ad hoc UI for some of my management activities. The attached script lets me take data and wrap it in a super-simple UI. At the top, I have a multi-column listview showing the data. At the bottom, I can have buttons with scriptblocks attached to them to act on the selected rows. Simple stuff but useful. And quite general-purpose.

Here are a couple of usage examples. I showed a variation on this during my VMworld talk this year:

out-form -title "Disconnect Devices From…" `
              -data (get-vm) -columnNames ("VM", "Floppy Count", "CD Count") `
              -columnProperties ("Name", "FloppyDrives.Count", "CDDrives.Count") `
              -actions @{"Disconnect" = {$_ | get-cddrive | set-cddrive -nomedia `
                               -confirm:$false; $_ | get-floppydrive | set-floppydrive -nomedia `

This gives me a list of VMs along with the number of floppy and CD drives for each. I select one or more, push the "Disconnect" button, and the floppy and CD devices are disconnected. With a little PowerShell command-line (and a little bit of scripting backing it), we have a custom application. Now take that command, drop it in a .ps1 file alongside the out-form script and we have a packaged, redistributable application. Cool. 🙂

Unless you’ve got an early access copy of our PowerShell cmdlets, you can’t try the example above yet. But here’s an example you can try:

out-form -title "Services" -data (get-service) `
              -columnNames ("Name", "Status") `
              -columnProperties ("DisplayName", "Status") `
              -actions @{"Start" = {$_.start()}; "Stop" = {$_.stop()};}


This obviously isn’t the most interesting use case. After all, Windows already has a service manager. The interesting uses will come from things you do in your environment. For me, that’s virtualization management, thus the example above. If you think this might be useful, download the script and try wrapping a UI around something you manage. Use it yourself. Hand your newly-created app to a coworker. If you find this useful, I’d love to hear about how you use or improve it.

Here’s the script: 

Download out-form.ps1

Hopefully the parameters are self-explanatory. Here’s a quick summary of each just in case:

1. title – title string to display

2. data – the objects providing the information to render

3. columnProperties – the properties of the data to display, one per column

4. columnNames – name to give each column. If not specified, the property names will be used (columnProperties). If specified, columnNames must be the same size as columnProperties

5. actions – an associative array mapping names to scriptblocks. Each name string will have its own button with the accompanying scriptblock linked to its click event. If not specified, no buttons will appear.

Antonio Dias

Early Access (Technology Preview)

We’re preparing a technology preview of the PowerShell interfaces for VI discussed in this blog.  If you’d be interested in receiving an early version of that software and you’d be willing to try it out and send us feedback, please send email to vi_tk_4win-admin@vmware.com.  Please include your name, company, contact info and a very brief description of your experience with PowerShell, with VI management, and with VI integration (via scripting or programming).

We look forward to hearing from you.


  Harvey Alcabes
  Product Marketing Manager