PowerCLI SpeedBoost: Advanced functionality hidden within Get-View

Everyone knows how to use the Get-View cmdlet to retrieve the full managed object from a VI implementation (Impl) object, but did you know you can skip the Impl entirely? For instance have you ever needed the following?

If so you may want to try:

I’ve found the latter to be around 1200% faster!  Additionally, by selecting the properties of interest at run time  an additional performance boost can be obtained.  For example suppose you just wanted the Name of every ESX host in vCenter.

is 300% faster then the traditional

When you really need to optimize you VI Scripts just add some filters. For instance a 400% performance boost can be obtained by replacing,


but what if you need the Impl object?  It’s still 150% faster to convert back from the managed object that to retrieve then to get the impl in the first place.

Finally the grand pooh-bah of hidden potential… nested parameters within filters!  Say you want to locate all windows vm’s that have out of date tools.

traditionally we would approach this with something like,

Wait for it….

Over 800% faster and WAY less code! Although using get-view to it’s full potential can seriously increase your scripts performance I would leave it in your scripts.   The cmdlets provided in the PowerCLI are built around an interactive experience, the SDK is NOT!  While it may be faster to get all vm’s with get-view. The information returned from Get-VM is more useful when working from the cmdline.

Happy Scripting,

Bonus:  The function I was writing when I discovered this enhanced functionality… that’s right it was hidden in the help.

8 thoughts on “PowerCLI SpeedBoost: Advanced functionality hidden within Get-View”

  1. Great article as always Glenn.
    It seems we were playing with the same cmdlet over the weekend 😉

    What do you mean with “…can seriously increase your scripts performance I would leave it in your scripts.”? Should it be in or out ?

  2. Yeah, that didn’t make much sense… My point was, these optimizations will provide the most bang for the buck in a script/function. While it is faster it’s not worth compromising the ease of use the cmdlets provide.

    get-vm “vm1” | remove-snapshot -confirm:$False

    is easier to remember and less typing then;

    Get-View -ViewType “VirtualMachine” -Filter @{“Name”=”vm1”}| %{$_.RemoveAllSnapshots()}

    Short version, yes it’s faster, but the cmdlets are fast enough for all the day to day stuff.

  3. Hi Glenn,

    How would this work for objects that are arrays such as customvalue?


    $TestVM = Get-View -ViewType “VirtualMachine” `
    -filter @{

    foreach ($vm in $TestVM){
    $vm.name $vm.customvalue[3]

    • Paul,

      To the best of my knowledge there is no way to filter on array’s. You can walk as far down a managed object as you desire as long as you don’t run into any arrays. If I ever find a work around, or if there is a change that enables such, I’ll be sure to pass it along.

      To be fair though this functionality is kinda niche.

  4. Paul,

    A big thanks for these tips here. I actually had a script that I set to use get-vmhost and get-vm to generate my array of machines to work with for a vmdk file report I had to generate. The original script was taking over 10 hours and now it’s down to an amazing 30 minutes.



  5. Glenn,

    Thanks, this helped out a lot, just modified a few scripts with your performance findings and it helped out a lot!


  6. Get-View -ViewType “VirtualMachine” `
    -filter @{
    } | Select-Object -Property Name, @{

    This is giving duplicate result. Not sure why. any suggestion?


Leave a Reply