Virtual Machine Manager’s PowerShell Support

One of the cornerstone features of System Center Virtual Machine Manager (SCVMM) is PowerShell. They have built their entire GUI layered on top of PowerShell in the same way that Exchange 2007 did. A little while ago, I talked to Rakesh Malhotra (the Group Program Manager for SCVMM) about how things were going and he was very pleased with their bet on PowerShell. He talked about how their task-oriented Cmdlets provided a very user approachable scripting experience. I asked him for a few examples so he sent me a set of comparisons with VMWare’s scripting experience (the VMWare script came from their website: ).

Script to Disconnect Drives from Running Virtual Machines


vmwarelist=`vmware-cmd -l`                    
vmwarelist=`echo $vmwarelist | sed -e
‘s/ /*/g’`        
vmwarelist=`echo $vmwarelist | sed -e
‘s/.vmx/.vmx /g’`    
for vm in $vmwarelist

vm=`echo $vm | sed -e
‘s/*/ /g’`                
vm=`echo $vm | sed -e
‘s/ \//*/g’`

if [ `vmware-cmd “$vm” getstate | sed -e ‘s/getstate() = //’` = “on” ]
echo Looking @ $vm
IDEBUS=`seq 0 1`

for i in $IDEBUS;

echo BUS : $i
     IDEDEVICE=`seq 0 1`

for j in $IDEDEVICE;

“$vm” getconfig ide$i:$j.present | cut -f3 -d ” “`
if [ $PRESENT = “true” ]
“$vm” getconfig ide$i:$j.deviceType | cut -f3 -d ” “`
if [[ $TYPE == “atapi-cdrom” || $TYPE == “cdrom-image” ]]
             echo Found CDROM on IDE$i:$j
“$vm” disconnectdevice ide$i:$j

SCVMM PowerShell


$vms = Get-VM | where {$_.VMState eq Running}
$vms | Get-DVDDrive | Set-DVDDrive
$vms | Get-FloppyDrive | Set-FloppyDrive

Take a minute and compare the 2 scripts and ask the following questions:

  1. How long did it take to write this script?
  2. Do I understand what this script is REALLY doing?
  3. How comfortable would I be changing this script and putting it on my production servers?
  4. If there is a problem in the middle of the night and the operations people need to review this script to understand what is going on, am I going to get a call?
  5. At the end of the day, is this script going to save me time and money or cost me time and money?

I think you’ll find different answers for the different scripts.


Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at: