PowerCLI & vSphere statistics – Part 2 – Come together

The end of my previous post in this series, see PowerCLI & vSphere statistics – Part 1 – The basics, showed how you could get the statistical values for a specific day.

Depending on the point in time for which you request the values, the sampling interval will be different. For example Historical Interval 2 will return values measured over 30 minute intervals. See also the schematic I included in the previous post.

This sample interval is not always what you want for your reports. Suppose you want to always report hourly values and only for working hours during business days. This post will show you how to accomplish that.

The first thing we should consider is that with Historical Interval 3, the statistical values will be aggregated to 2 hour interval data. So if we need a 1 hourly interval, we should run the report no farther back than 1 week in the past.

There is an alternative where you export the statistical data to an external database, but that procedure will be a candidate subject for a future post in this series.

Custom sampling period

For the first requirement we have to find a way to aggregate the 30 minute interval data in 1 hour interval data. As it turns out this is quite easy with PowerShell. We can let the Group-Object cmdlet do that for us.

The following script shows how you could use this to get statistical values for 1 hour intervals. Make sure to read the Annotations since there are quite a few other gotchas in this script sample.

Note that I used several unnecessary intermediate variables in the script like $stats, $groups and $report. These are there for demonstration purposes or if you should want to run the script through a debugger.

I could in fact have used the PowerShell pipeline to chain all these steps together !

Annotations

Line 3: this is the trick I already explained in Part 1 of this series

Line 5: a regular Get-Stat call. Start to Finish is exactly 1 day.

Line 6: the Group-Object cmdlet uses 2 critera to create the groups. First the hour part of the timestamp, secondly the instance of the sample.

Line 7-18: each of the groups runs through these lines and the averaged values for the hourly intervals are calculated

Line 8: I could have used the same object that Get-Stat is returning (VMware.VimAutomation.Client20.FloatSampleImpl) but for whatever reason the PowerCLI team decided to make the Value property read-only.

Line 9-13, 15: These properties are copied from the first entry in the group, but that is ok since these properties are the same in all entries in each group

Line 14: This uses a small trick to get the start of the hour interval (since you can’t know, without sorting the group on Timestamp, which is the earliest Timestamp). I first take the “date” part of the Timestamp in the first entry and then add the Hour property of the same entry. This will always return a Timestamp “on the hour”.

Line 16: calculates the average of all the Values in the group. I used the .Net Round function to limit the result to 2 decimal digits.

Line 19: the script exports the data to a CSV file but you could chose whatever type of output you desire.

A quick look at the result:

Business hours/working days

The final requirement for our report was that we only wanted to see the values for business hours during working days. Again PowerShell to the rescue. The Where-Object cmdlet and some of the methods and properties of the DateTime object make this a breeze.

Annotations

Line 4: I use an array to define the days I’m interested in.

Line 5-6: I use the .Net DateTime constructor (with 6 arguments). This allows me to specify the time of day for the begin and the end of the period I want to report on. For the first 3 parameters (year, month, day) I could have specified any of the accepted values, later on in the script I will only use the Time part.

Line 10: The -contains operator is a very handy tool to use. It avoids a lot of nested ifs. In this line I check if the day of the week is one of those that I want to include in the report.

Line 11,12: Like I already explained above, I only consider the time of day part of the timestamp.

To show what the script does, these are the statistical values as they are returned by the Get-Stat cmdlet.

Some points about this data:

  • The Timestamp doesn’t always start exactly at midnight. Since the value that is reported with the 01:00 timestamp is the average value over the past 2 hours, you will have to decide if you want to include this in your reports
  • These values come from Historical Interval 3 where the sample interval is 2 hours.
  • Since I use statistical level 3 for Historical Interval 3, there are no values for the individual instances. Only the aggregate value is kept !

And this is what is in the final report. Only the values for the requested days of the week and only the ones between the requested hours.

Conclusion

As you noticed in this post it is very useful to know several PowerShell cmdlets besides the ones in PowerCLI. This will make your tasks a lot easier and will impress your management with the splendid reports you are producing in a matter of minutes.
In the next post(s) I’ll be looking in detail at several of the available metrics and what you can/could use them for.
If you have any questions on working with the Get-Stat cmdlet or on how to use the resulting data, feel free to post them as a comment to this post.

PS: the title of this post was in memory of one of my childhood heroes.

27 Comments

    Hossam

    Hey Luc!

    I’m a newbie in this!, so sorry it it is naive question.

    I want to run similar script gather Get-Stat standard metrics for all VMs in 1 cluster containing almost 300 VMs, and store them in 1 CSV or multiple CSVs one for each metric it 1 will be hard to gather every thing in 1 CSV.

    this should be run once a day gathering metrics for each VM in 5 minutes intervals,

    how to do, what to watch for?

      LucD

      Hi Hossam,
      Without going into too much details now, you should look at a few things:

    1. Minimise the number of calls to Get-Stat. Rather call it once for all VMs, and then use Group-Object to split out the results per VM. There are a couple of example in my other Statistics posts.
    2. Have a look at the ImportExcel module. It would allow you to split the results, per VM or per metric, over multiple worksheets in one XLSX file.
    3. Determine how much detail you want. Do you really need a value every 20 seconds? Or would a longer interval suffice for your purpose?
    4. Make a good, and meaningful, selection of the metrics you are collecting. Too many metrics means longer runs and bigger files.
    5. In summary, plan before you code your script!
      Regards,
      Luc

    kam007

    Hi Lucd,
    Your report is excellent and it is running successfully in our environment.
    I am learning PowerCli from your book.
    Currently I have a requirement that I want to fetch this report in HTML format and receive it in my email directly.
    If it is possible please let me know.
    ————————————————————————————
    When I am learning your book I found different type of special character and toke have been used in it. As I don’t know any programming language it is difficult to understand. So is it possible to know which programming language training will help me to understand the powercli scripting.

      LucD

      Hi Kam007,
      To send a report as an email, you can use the Send-MailMessage cmdlet.
      Something like this

      $esxName = 'MyEsx'

      $esxImpl = Get-VMHost -Name $esxName
      $todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1)
      $stats = Get-Stat -Entity $esxImpl -Stat cpu.usage.average -Start $todayMidnight.AddDays(-5) -Finish $todayMidnight.AddDays(-4)
      $groups = $stats | Group-Object -Property {$_.Timestamp.Hour, $_.Instance}
      $report = $groups | % {
      New-Object PSObject -Property @{
      Description = $_.Group[0].Description
      Entity = $_.Group[0].Entity
      EntityId = $_.Group[0].EntityId
      Instance = $_.Group[0].Instance
      MetricId = $_.Group[0].MetricId
      Timestamp = $_.Group[0].Timestamp.Date.AddHours($_.Group[0].Timestamp.Hour)
      Unit = $_.Group[0].Unit
      Value = [math]::Round(($_.Group | Measure-Object -Property Value -Average).Average, 2)
      }
      }

      $sMail = @{
      From = 'lucd@lucd.info'
      To = 'lucd@lucd.info'
      Subject = 'Report'
      BodyAsHtml = $true
      Body = $report | ConvertTo-Html | Out-String
      SmtpServer = 'mail.lucd.info'
      }

      Send-MailMessage @sMail

      On your other question, I’m not sure which special tokens you mean.
      But there are several great learning resources for PowerShell and PowerCLI available.

      Some examples:
      PowerShell study guide – core concept
      PowerCLI study guide – core concepts

      And doing a search for ‘powershell training free’ will bring up a bunch of other resources.

      I hope this helps.
      Luc

    MCheung

    Dear LucD,

    My user is using the below Get-Stat commands on vCenter 5.1 to collect the performance data for the VM ‘VM0000’ daily.

    Get-Stat -entity VM001A -stat cpu.usage.average -Start -finish
    Get-Stat -entity VM001A -stat mem.usage.average -Start -finish
    Get-Stat -entity VM001A -stat disk.usage.average -Start -finish

    The above commands are executed every day, at 0:20 am, to collect the data for the previous day. The sampling interval is 5 minutes until the VM was powered off for about 20 hours for system maintenance.

    After the VM was powered on again, the sampling interval was changed from 5 minutes to 30 minutes on the day the VM was powered on.However, the next day after the VM was powered on, the sampling interval was back to 5 minutes again.

    Any ideas or explanation on this behavior? Thanks.

    Malik

    Hi LucD
    I am try to workout on a script to find out the average CPU, Memory usage for last month. But just for working hours and week days.

    i.e. For each VM I need average CPU, memory usage calculated against working hours (8am to 6pm). Also this should skip weekdays. I understand for 1 month report I can have two hours interval (HI3) which is alright in my case. below is the script I am trying out. but it is not working.

    Value Timestamp MetricId Unit Entity
    22.19 31/08/2012 cpu.usage.average % APPS1
    8.14 30/08/2012 cpu.usage.average % APPS1
    7.49 29/08/2012 cpu.usage.average % APPS1
    7.53 28/08/2012 cpu.usage.average % APPS1

    sam

    @LucD
    I also try to get more info just like “-Stat cpu.usage.average,Mem.Usage.Average,disk.Usage.Average”,but seen doesn’t work?

    sam

    @LucD
    Really thank your for your help !!! but I try this script , it produce performance data every minutes , even change the $interval value to 300 , did something wrong ? Should I add -IntervalSecs $interval with get-stat command?

    sam

    Dear LucD

    did it possible to use “get-stat” to monitor the host or vm stat ,

    just like every 5 mins write one performance data to csv file , and create a csv file for each day ,

    I can write performance data to csv file once , but can`t write again into the same csv file ,

    Do you have any suggestions ???

      LucD

      @Sam, yes that is possible.
      The following script will get the average CPU of an ESX(i) host every 5 minutes during 24 hours.

      $esxName = "MyHost"
      $esx = Get-VMHost -Name $esxName
      $interval = 300 # Time interval in seconds

      $fileName = "C:\" + $esxName + "-cpu-5mins.csv"
      $now = Get-Date
      $end = $now.AddHours(24)

      while($now -le $end){
      $next = $now.AddSeconds($interval)

      if(Test-Path -Path $fileName){
      $report = @(Import-Csv -Path $fileName -UseCulture)
      }
      else{
      $report = @()
      }

      $report += (Get-Stat -Entity $esx -Stat cpu.usage.average -Realtime -MaxSamples 1 -Instance "" |
      Select @{N="Hostname";E={$_.Entity.Name}},Timestamp,Value)

      $report | Export-Csv -Path $fileName -NoTypeInformation -UseCulture -Confirm:$false

      $wait = ($next - (Get-Date)).Seconds
      if($wait -gt 0){
      sleep -Seconds $wait
      }
      $now = Get-Date
      }

      As you correctly observed, there is no append option for the CSV cmdlets. The solution is to Import and Export the CSV file each time with the complete data. Not the most elegant way, but the only one I know of without actually appending the CSV rows directly.

    TonyG

    @LucD
    Sorry to dual post, but did not seem to show up here in a timely fashion and figures the PS community would benefit from your guidance 🙂
    TG

      LucD

      @TonyG, no problem. When I’m at work I don’t look that often at my blog comments. So it can take a bit of time before you see a comment appearing 😉

    TonyG

    Hi LucD,

    Firstly – thanks for a great post, I’m certainly not any good at PowerShell – but I was able to understand and make some changes for my benefit – so I figured I’d share my results and ask a couple of questions.
    With your script as a basis – I’ve been able to come up with the following that SHOULD allow me to review ALL VC machines in VC one at a time collect virtual disk stats for the VM’ various disks, (IOPS, Throuput & Latency) I’m using VC 4.1 and I believe these stats are OK (but would appreciate your insight on this).
    I’m quite pleased with the script – but it needs more testing on a valid site, rather than my small test area, but I’m sure from a ‘PS’ perspective there is more efficiency to be gained.
    Firstly – is there any way of getting all the stats at once – rather than doing 6 calls per VM? Also – is there a way can control the output to the CSV, it seems to put colums in any order it likes and layout does not seem to be related to the group object command? Can this be controlled so I can have the ‘value’ and ‘unit’ entries next to each other?

    Any insight and assistance would be appreciated, and I hope other will give it a test and let me know if it works for them too.

    Thanks again for the inspiration and insight that got me this far 🙂

    Tony.

    # Main Variables
    $sVCentre = “VC IP”
    $sVCUser = “administrator@domain”
    $sVCPwd = “password”
    $strVMWildCard = “*”
    $strCSVName = “Stats-AvgVMDiskWriteStatsWorkingday”
    $strCSVLocation = “c:\”

    # define the start and finish times for a working day.
    $today9am = (Get-Date -Hour 9 -Minute 0 -Second 0)
    $today5pm = (Get-Date -Hour 17 -Minute 0 -Second 0)
    $intStartDay = -1
    $intEndDay = -1

    ## Begin Script

    #Connect to VC
    Connect-VIServer $sVCentre -User $sVCUser -Password $sVCPwd -ea silentlycontinue
    $arrVMs = Get-VM | where-object {$_.Name -like $strVMWildCard}
    foreach ($strVM in $arrVMs)
    {
    Write-Host “Getting Stats for : ” $strVM.Name
    Write-Host ” – collating Write latency Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.totalWriteLatency.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host ” – collating Read latency Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.totalReadLatency.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host ” – collating Read IOPS Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.numberReadAveraged.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host ” – collating Write IOPS Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.numberWriteAveraged.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host ” – collating Read Throughput Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.read.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host ” – collating Write Throughput Stats”
    $stats += Get-Stat -Entity $strVM -Stat virtualDisk.write.average -Start $today9am.AddDays($intStartDay) -Finish $today5pm.AddDays($intEndDay)
    Write-Host $stats.length

    # group the data and collate the stats into averages for the day.
    }$groups = $stats | Group-Object -Property {$_.Entity, $_.MetricId, $_.Instance}
    $report = $groups | % {
    New-Object PSObject -Property @{
    Description = $_.Group[0].Description
    Entity = $_.Group[0].Entity
    EntityId = $_.Group[0].EntityId
    Instance = $_.Group[0].Instance
    MetricId = $_.Group[0].MetricId
    Timestamp = $_.Group[0].Timestamp.Date.AddHours($_.Group[0].Timestamp.Hour)
    Unit = $_.Group[0].Unit
    Value = [math]::Round(($_.Group | Measure-Object -Property Value -Average).Average, 2)
    }
    }
    #Exporting the report to a CSV file.
    $strCSVSuffix = (get-date).toString(‘yyyyMMddhhmm’)
    $strCSVFile = $strCSVLocation + $strCSVName + “_” + $strCSVSuffix + “.csv”
    $report | Export-Csv $strCSVfile -NoTypeInformation -UseCulture

      LucD

      @TonyG, thanks, appreciated.
      I replied to your questions in the PowerCLI community thread.
      See your thread Using PowerCLI to get VM Disk Stats

    DK

    LucD,

    Great site. Do you have a ps script that could just show total IOPS of all VMs in a particular datacenter or cluster? Basically query the VM disk cmd/s avg for the last week or month and put in a csv file so we can sort 10 top or bottom 10? Does that make sense?

    Alex

    is it possible to extract a daily cpu.usage.average and mem.usage.average settings an interval?
    i’m not be able to report lasto 30 days cpu and mem usage average.
    At moment i’m be able to extract monthly (or last 30days) cpu and mem average.
    Someone can help me?
    At moment i use the Business hours/working days SCRIPT.

    VM Noobie

    Hi LucD,

    I skimmed through your Part 3 and understand it’s pretty focused on getting statistics related to disk. My question is, is it possible to take the same approach using your scrip from above (Part II) to gather statistics for a VM? I haven’t tried it yet but is it as simple as using Get-VM? Thanks.

      LucD

      As you can see from the table at the beginning of that post, there are several metrics (especially the latency ones) that are not available for virtual machines but only for ESX/ESXi hosts.
      In the SDK Reference, under PerformanceManager, you can find very useful tables that show, in the Entity columns, which metric is available for which type of object. See for example the table about the Disk I/O Counters.
      Watch the series, there will be other posts 😉

    VM Noobie

    Greetings LucD —

    Sorry to beat this to a dead horse but I’m attempting to somewhat combine the two scripts and capture 1 HR interval data during business hours. I basically took lines 4,5,6 from the second script and moved it up to the first script in hopes that it would be that simple. Any thoughts? Thanks.

      LucD

      For the record, the following is the script that we ended up with.

      $esxImpl = Get-VMHost

      $todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1)

      $workingDays = “Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”
      $dayStart = New-Object DateTime(1,1,1,5,00,0) # 05:00 AM (Take into account EST)
      $dayEnd = New-Object DateTime(1,1,1,19,00,0) # 06:00 PM

      $date = Get-Date

      $filename = “VMware_HostCPU1HR_{0}{1:d2}{2:d2}.csv” -f $date.year,$date.month,$date.day

      $stats = Get-Stat -Entity $esxImpl -Stat cpu.usage.average -Start $todayMidnight.AddDays(-5) -Finish $todayMidnight.AddDays(-4) | `
      Where-Object {
      $workingDays -contains $_.Timestamp.DayOfWeek -and
      $_.Timestamp.TimeOfDay -gt $dayStart.TimeOfDay -and
      $_.Timestamp.TimeOfDay -lt $dayEnd.TimeOfDay
      }

      $groups = $stats | Group-Object -Property {$_.Entity, $_.Timestamp.Hour, $_.Instance}
      $report = $groups | % {
      New-Object PSObject -Property @{
      Description = $_.Group[0].Description
      Entity = $_.Group[0].Entity
      EntityId = $_.Group[0].EntityId
      Instance = $_.Group[0].Instance
      MetricId = $_.Group[0].MetricId
      Timestamp = $_.Group[0].Timestamp.Date.AddHours($_.Group[0].Timestamp.Hour)
      Unit = $_.Group[0].Unit
      Value = [math]::Round(($_.Group | Measure-Object -Property Value -Average).Average, 2)
      }
      }

      $report | Export-Csv “C:\$filename” -NoTypeInformation -UseCulture

      The two important changes:
      1) add the “where” cmdlet to filter the statistical data
      2) add the Entity property to the Group-Object cmdlet to have the script report on multiple servers

    VM Noobie

    Looks like this happened simultaneously with your suggestion, I did the sanity check and yes it did work with PS v2 RTM! It’s all the small things that matter. Thanks again. I’m sure you’ll be hearing from me soon enough. ~cheers

    VM Noobie

    I was hoping it was something simple but I’ve been using PowerShell v2 CTP3 to run this.

      LucD

      My first advise is to upgrade to PS v2 RTM but you can easily use the “old” method of doing this (with New-Object and Add-Member cmdlets).
      Have a look at New-Object PSObject –Property [HashTable], it shows the “old” and the “new” method.

    VM Noobie

    First off, awesome website and many thanks for sharing all your PowerShell knowledge. I’m sure many could attest to that. Anyway, I am trying to obtain Historical Interval 2 statistics and basically ran the first script on the top of this page. This is what I am encountering. Any thoughts?

    — ——–
    New-Object : Member “Entity” not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "MetricId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Timestamp" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Unit" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "EntityId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Description" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Instance" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Value" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Entity" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "MetricId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Timestamp" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Unit" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "EntityId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Description" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Instance" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Value" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Entity" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "MetricId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Timestamp" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Unit" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "EntityId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Description" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Instance" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Value" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Entity" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "MetricId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Timestamp" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Unit" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "EntityId" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Description" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Instance" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Value" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

    New-Object : Member "Entity" not found for the given Net object.
    At C:\DOCUME~1\x647855\LOCALS~1\Temp\c14a2fc5-a326-40ab-b788-f9c80e4dfe88.ps1:1
    1 char:12
    + New-Object <<<< PSObject -Property @{
    + CategoryInfo : InvalidOperation: (:) [New-Object], InvalidOpera
    tionException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C
    ommands.NewObjectCommand

      LucD

      Thanks.
      Could it be that your using PowerShell v1 ?
      The New-Object PSObject -Property @{…} construct I used is only available since PowerShell v2.

    daniel

    Great tutorial, thanks! This will certainly come in handy when looking at which VM resources are under-/overutilized.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.