Several months ago I created a Visual Basic program named VMCDConnected. This application checks if one of your virtual machines is connected to an ISO image. When you have created a DRS cluster the virtual machines in this cluster are automatically migrated to the least busy ESX host. These migrations depend on VMotion. The most common show stopper for VMotion is a connected CD that’s not on shared storage. With one click of a button all the CD’s are disconnected. This weekend I had the change to try out the VMware Infrastructure Toolkit for Windows. It provides a core set of Windows PowerShell cmdlets for managing VI. Within minutes I created a script with the same features as my Visual Basic application. The difference is that creating the Visual basic program took me over a month. One other big difference is that the PowerShell script only counts five lines of code. The image shows a glimpse of the Visual Basic Object Browser investigating the Toolkit’s classes and properties. Building Visual Basic application on top of the Toolkit will also become a lot easier.
For the creation of the five-liner I used the script editor from PowerGui and the VMworld presentation “Managing VMware Infrastructure with Windows PowerShell� presented by Antonio Dias and Danny Kim. VMware is preparing a technology preview of the PowerShell. If you'd be interested in receiving an early version of that software and you'd be willing to try it out and send them feedback, please send email to vi_tk_4win-admin@vmware.com.
Add-PSnapin VMware.VimAutomation.Core
Get-VIServer vcserver.local
$vms = Get-VM
$CDConnected = Get-CDDrive $vms | where {$_.ISOPath -like "*.ISO*"}
Set-CDDrive -connected 0 $CDConnected