VMware Cloud Community
Madmax01
Expert
Expert

get-view slow

Hi guys,

i tried to find an Answer why is slower then default query.

may anyone have an Idea  why get-view is that slow in comparison to get-vm


about 4021 vms.

Measure-Command {get-vm}

Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 1

Milliseconds      : 982

Ticks             : 19822577

TotalDays         : 2.29427974537037E-05

TotalHours        : 0.000550627138888889

TotalMinutes      : 0.0330376283333333

TotalSeconds      : 1.9822577

TotalMilliseconds : 1982.2577

Measure-Command {Get-View -viewtype VirtualMachine}

Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 53

Milliseconds      : 3

Ticks             : 530030273

TotalDays         : 0.00061346096412037

TotalHours        : 0.0147230631388889

TotalMinutes      : 0.883383788333333

TotalSeconds      : 53.0030273

TotalMilliseconds : 53003.0273

$gvProps = "Name","config.hardware.numcpu","summary.quickstats.OverallCpuUsage","summary.runtime.powerState"

Measure-Command {Get-View -viewtype VirtualMachine -Property $Props}

Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 3

Milliseconds      : 548

Ticks             : 35483428

TotalDays         : 4.10687824074074E-05

TotalHours        : 0.000985650777777778

TotalMinutes      : 0.0591390466666667

TotalSeconds      : 3.5483428

TotalMilliseconds : 3548.3428

Get-View -viewtype VirtualMachine -Property $Props -Filter @{"summary.runtime.powerState"="PoweredOn"}

Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 4

Milliseconds      : 332

Ticks             : 43328185

TotalDays         : 5.01483622685185E-05

TotalHours        : 0.00120356069444444

TotalMinutes      : 0.0722136416666667

TotalSeconds      : 4.3328185

TotalMilliseconds : 4332.8185

thx

Max

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

The Get-VM cmdlet is optimised, none of the other cmdlets are (afaik).

Also, with the Get-VM the ExtensionData part is not there immediately.

If you access properties in there, after a Get-VM, you should notice the execution times increasing.

In summary:

  • the Get-VM cmdlet is optimised
  • the objects returned by Get-VM and Get-View ViewType VirtualMachine are not the same. You are comparing apples with pears.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Madmax01
Expert
Expert

Hi LucD,

thx for the Answer.

i'am confused about comparing  "apples with pears".

there where lot's  topics about this in the Past (get-vm/get-vmhost etc,.. vs get-view).  and i remember i had to change all my Coded to get-view commandings > as they where absolutly fast. which it was.
To be honest i didn't noticed with which version the normal cmdlets where optimized and get-view went slow,......... i just wondered recently during comparisons

Example:

Get-View Part 3: Peformance Impact - Is it really THAT much different? - VMware PowerCLI Blog - VMwa...

i just recognized during multiple  get-view that something not right.  so i checked "UpdateViewData"  which still was slow.  after used the extensiondata,.... that went speedy through.

but seems that was all Past Story.  i will look to change my code to get-vm

thx Luc. have good weekend

thx

Max

Reply
0 Kudos
LucD
Leadership
Leadership

Just be aware that only Get-VM is optimised that way.

For all other Get cmdlets it will most probably be faster to use Get-View, and preferably only with the properties you actually need.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership

On my "apples and pears" claim, just feed the output of both cmdlets to Get-Member.

You'll notice that the Get-VM returns a different object than Get-View for the VirtualMachine type.

In short, the VirtualMachine object that Get-VM produces is a collection of properties that the PowerCLI Dev Team selected.

The output of Get-View is the complete object as document in the API Reference under VirtualMachine

An even better view on the differences can for example be obtained by piping the objects in both cases to Format-Custom -Depth 10.

Watch out, this produces a lot of output (redirect to a .txt file)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Madmax01
Expert
Expert

Thank you for the Infos Smiley Wink was Helpfully Smiley Wink

Reply
0 Kudos