Virtual Machine Manager’s PowerShell Support

  • Comments 17

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:

Leave a Comment
  • Please add 6 and 4 and type the answer here:
  • Post
  • 1) Aliases can map to anything not just cmdlets that is why the parameter name is -VALUE

    2) We should have REMOVE-ALIAS.  Full stop.  We prioritized other features.  The way you do it is:

    Remove-Item Alias:name

    I'd appreciate the details for #4.  V2 should run V1 scripts with perfect fidelity modulo bug fixes.


  • Hi Jeffrey,

    I installed SCVMM 2008 R2, but I couldn't find the cmdlet Get-DVDDrive as you used in your article.  Can you please give me some pointers on how to use the powershell scripts shipped with SCVMM?



Page 2 of 2 (17 items) 12

Virtual Machine Manager’s PowerShell Support