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 4 and 1 and type the answer here:
  • Post
  • Reaction:

    This is self-serving marketing crap! Another item of evidence in the category,

    "Why should I build for MS when they'll undermine what I have built on their platform eventually?"

    Now I think PowerShell rocks. I think what the various teams inside Microsoft are doing to leverage PowerShell rocks. I think it is great that other are building providers and cmdlets in small ISVs. I expect other vendors who sell product on the MS platform will follow too. Unless MS alienates too many of them and their customers.

    I think negative comparison with competing products is a quick way to continue to alienate.

  • Well this required a cmdlet (or two ) to be written for PowerShell... it could just have easily be done differently.

    Bottom line - does it work?

  • > I expect other vendors who sell product on the MS platform will follow too.

    Right!  I'm not trying to compare products, I'm trying to compare abstractions and scripting techniques.

    Anyone can leverage PowerShell to produce the right abstractions for customers.  That is exactly the point.  Everyone can and everyone should.  

    Jeffrey Snover [MSFT]

    Windows PowerShell/Aspen Architect

    Visit the Windows PowerShell Team blog at:

    Visit the Windows PowerShell ScriptCenter at:

  • Jeffrey,

    Interesting post. As I have said in my blog (, there are simpler ways to disconnect media from VMware virtual machines. VBScript can be used together with the VMware COM APIs.

    Of course, being able to do it with PowerShell commands is great because it can really simplify things. Exchange Server 2007, in my view, has already proven this.

    Now I am just hoping that some 3rd party would write some PowerShell plugins to work with VMware's Virtual Infrastructure. VMware has a complete web services API that can be leveraged from .NET so it is just a matter of connecting the dots so to speak.


    Geert Baeke

  • The great bit about powershell cmdlets is the write once use many capability.  This is a prime example.  Once the cmdlets are written they can be used in a simple way to acheive the desired outcome.  The learning curve for pipling two or three cmdlets is a lot less than producing a 30+ line script.  The productivity gains are not to be sniffed at either

  • > Now I am just hoping that some 3rd party would write some PowerShell plugins to work with VMware's Virtual Infrastructure. VMware has a complete web services API that can be leveraged from .NET so it is just a matter of connecting the dots so to speak.

    I bet that the PowerShell Community Extensions project ( )would be very interested in those cmdlets if someone writes them.  If the instrumentation exists, writing the cmdlets is a pretty straightforward task.

    Jeffrey Snover [MSFT]

    Windows PowerShell/MMC Architect

    Visit the Windows PowerShell Team blog at:

    Visit the Windows PowerShell ScriptCenter at:

  • I think this is a great example of how PowerShell compares to more traditional scripting approaches. Don't read this as a "dig" on VMWare ("the competition"); read it as a dig on what administrators have been forced to work with. VBScript isn't so different from this VMWare-specific example; what makes PowerShell workable and more approachable is the fact that it's concise and is useful even for ad-hoc tasks - you don't need to "develop" a complex script to do complex things. This is a great comparison not of competing products, but of competing philosophies in command-line administration. PowerShell benefits from being DESIGNED for this purpose; shell scripts have traditionally "evolved" into what they are, rather than having an overarching design that's specific to administrative tasks.

  • I don't get it. This is nothing special. Some dude had to go and write 3 cmdlets to make this happen. The same dude could have written 3 bash scripts to source. Same stuff.

    There is no magic here.

    The difference is in the Linux world, we already have thousands of 'cmdlets', because people focus on writing the command line interface before the UI, instead of the other way around.

    It's a bit disingenuous to suggest that PowerShell somehow makes this situation any different.

  • Clive beat me to it again! PowerShell uberguru Jeffrey Snover has blogged " Virtual Machine Manager’s

  • Jerry, the difference is that in the Windows world we DON'T already have thousands of cmdlets. I think you may have looked at the comparison differently; this isn't Linux vs. Windows. This is Windows vs. Windows - that is, an older way of scripting vs. a newer way - something that we haven't had. Yes, a Linux script was used, but it's substantially similar to what we'd have had to do on Windows, too. Your point about how Linux focuses on the command line before the UI is exactly the point of PowerShell. No, it's not earth-shattering for the IT industry as a whole - but for Windows, it is - we've never been ABLE to think like this. PowerShell DOES make the situation different - for Windows. Since PowerShell isn't made for Linux, Linux really "don't enter into it," apart from the fact that PowerShell borrows a lot of great ideas from *nix and brings them to Windows.

  • Hello,

    Those 2 scripts cannot be compared, they aren't based on the same VMWare utilities (vmware-cmd)

    Just rewrite the powershell script using the vmware-cmd, and then you can compare it. I can write the same type of your powershell script using bash, using my own own cmdlet developed for that

  • Those who have pointed out that Virtual Server cmdlets had to be written are, I think, missing the point: VMware commands also had to be written. Indeed, the designs of the respective cmdlets/commands are an important part of the comparison, in my view.

    The point, as I see it, is to show the difference in philosophies, with the VMware commands being based on the traditional Unix model of generating and processing text streams, whereas the Virtual Server cmdlets are based on the PowerShell model of interacting with self-describing objects.

    You could use PowerShell to process text streams generated by something like vmware-cmd, but that wouldn't be making use of the object-based nature of the shell, which is one of its key advantages over traditional shells like bash, and hence would be rather pointless. On the other hand, a traditional shell like bash doesn't include any notion of objects, so simply isn't capable of working in the way that PowerShell does.

  • Thomas - you're making the right point. We were able to use Powershell and its constructs to create an excellent "user interface" for scripting. Sure, we had to write the cmdlets but now you don't have to.

    In fact, our entire user interface for SCVMM is built on top of powershell which means our UI developers use it as their API. That type of approach forces a certain amount of rigor and thought in your scripting interface design. Our API is your API. If it's hard to script for you, it's hard to write and maintain code for us as well. With the object-based constructs that powershell provides, this type of design decision was a no-brainer for us and it keeps us honest with customers.

  • I'd have to say that I'm pretty impressed with how easy it is to write scripts for SCVMM using PowerShell.  The hardest part is that there isn't any documentation yet and there aren't many people blogging about it.  Your code sample was about the only peice of sample code that I could find, yet from that I was able to work out how to start and stop VMs and create checkpoints without too much trouble.  I've posted my progress at and have included some sample scripts that I have created.

    I've done quite a bit of scripting with vbscript and can say that PowerShell is a lot easier work with.  I have to point out though that I when it comes to virtualisation,  Microsoft have a lot of catching up to do before they can compete with VMWare.  Having said that, the company that I work for almost exclusively uses Microsoft products so SCVMM is very warmly welcomed!

  • I have given up on powershell as a scripting language because:

    1) I tried to establish an alias without the book in front of me. You try it "Get-Help Set-Alias" now which is the alias and which is the commandlet. Please note that I did look in the book and the syntax given there is not what "Get-Help Set-Alias" returned.

    2) There is no "Delete-Alias" so my only option was to uninstall the product and the reinstall. Is this how to run a railroad (or language)?

    3) Because in the two MS books (Step by Step & Guide) that I have the string methods are essentially undocumented I wrote a script using what I could find (including stuff on .VBS). Then I started writing the script that I wanted.

    4) The two scripts behave quite differently (under both v1 and v2 of PS) even though they are syntactically identical. The error messages only further demonstrate PowerShell's inadequacy.

    5) A null string obviously does not "Contain" anything so the result should be "False" not an error message.

    If you send me an e-mail at yahoo I would be happy to reply with additional documentation.  

Page 1 of 2 (17 items) 12

Virtual Machine Manager’s PowerShell Support