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 !
$esxName = "my-ESX-hostname"
$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)
}
}
$report | Export-Csv "C:\Hourly-cpu.csv" -NoTypeInformation -UseCulture
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.
$esxName = "my-ESX-hostname"
$esxImpl = Get-VMHost -Name $esxName
$todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1)
$workingDays = "Monday","Tuesday","Wednesday","Thursday","Friday"
$dayStart = New-Object DateTime(1,1,1,7,30,0) # 07:30 AM
$dayEnd = New-Object DateTime(1,1,1,17,30,0) # 05:30 PM
$stats = Get-Stat -Entity $esxImpl -Stat cpu.usage.average -Start $todayMidnight.AddDays(-14) -Finish $todayMidnight.AddDays(-7)
$report = $stats | Where-Object {
$workingDays -contains $_.Timestamp.DayOfWeek -and
$_.Timestamp.TimeOfDay -gt $dayStart.TimeOfDay -and
$_.Timestamp.TimeOfDay -lt $dayEnd.TimeOfDay
}
$report | Export-Csv "C:\BusinessHours-cpu.csv" -NoTypeInformation -UseCulture
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.





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?
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.
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.
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
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.
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
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
I was hoping it was something simple but I’ve been using PowerShell v2 CTP3 to run this.
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.
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
Thanks.
Could it be that your using PowerShell v1 ?
The New-Object PSObject -Property @{…} construct I used is only available since PowerShell v2.
Great tutorial, thanks! This will certainly come in handy when looking at which VM resources are under-/overutilized.