Page 1 of 1

Performance Data via Powershell

Posted: Jan 30, 2019 2:20 am
by Michael.Aksoy
Hi,

How can I get the snapshot information from SCOM Via Powershell?

Below is my code:

CLS
Import-Module OperationsManager

$Class = Get-SCOMClass -DisplayName "VMWare Virtual Machine"
$ClassInstance = Get-SCOMClassInstance -Class $Class


$Snaps = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotAgeHours"} | Select MonitoringObjectDisplayName, LastSampledValue



$Size = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotsSizeMB"} | Select MonitoringObjectDisplayName, LastSampledValue
$storageUsed = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "usedStorageGB"} | Select MonitoringObjectDisplayName, LastSampledValue


No value is returned by LastSampledValue, but in SCOM on the dashboards I see a value. I need to pull this information via Powershell. Any help on this would be great.

Re: Performance Data via Powershell

Posted: Jan 30, 2019 2:34 pm
by wishr
Hi Michael,

Welcome to Veeam Community Forums and thanks for posting your question.

"LastSampledValue" does not work for us either, but we've taken a look at that article and as a result, created the below scripts:

Code: Select all

CLS
Import-Module OperationsManager

$Class = Get-SCOMClass -DisplayName "VMWare Virtual Machine"
$ClassInstance = Get-SCOMClassInstance -Class $Class

$Snap = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotAgeHours"} | 
Select MonitoringObjectDisplayName, @{Name = "SnapshotAgeHours"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+/- [UTC difference -1]),(Get-Date).addHours(+/- [UTC difference])) | Select -Last 1}}}

$Size = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotsSizeMB"} | 
Select MonitoringObjectDisplayName, @{Name = "snapshotsSizeMB"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+/- [UTC difference -1]),(Get-Date).addHours(+/- [UTC difference])) | Select -Last 1}}}

$StorageUsed = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "usedStorageGB"} | 
Select MonitoringObjectDisplayName, @{Name = "usedStorageGB"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+/- [UTC difference -1]),(Get-Date).addHours(+/- [UTC difference])) | Select -Last 1}}}
Please note, the following:
  • You have to cut off the "+/- [UTC difference]" everywhere and replace it with an applicable value representing the time difference between local TZ set on the machine running PowerShell and UTC TZ, since SCOM stores all the data in the UTC TZ.
  • PowerShell should be launched elevated.
Script example for UTC-8 TZ:

Code: Select all

$Snap = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotAgeHours"} | 
Select MonitoringObjectDisplayName, @{Name = "SnapshotAgeHours"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+7),(Get-Date).addHours(+8)) | Select -Last 1}}}

$Size = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "snapshotsSizeMB"} | 
Select MonitoringObjectDisplayName, @{Name = "snapshotsSizeMB"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+7),(Get-Date).addHours(+8)) | Select -Last 1}}} 

$StorageUsed = $ClassInstance.GetMonitoringPerformanceData() | ?{$_.CounterName -eq "usedStorageGB"} | 
Select MonitoringObjectDisplayName, @{Name = "usedStorageGB"; expression = {Foreach-Object {$_.GetValues((Get-Date).AddHours(+7),(Get-Date).addHours(+8)) | Select -Last 1}}}
Hope this helps!

Regards,
Fedor

Re: Performance Data via Powershell

Posted: Jan 31, 2019 1:41 am
by Michael.Aksoy
Hi,

Thanks for your reply. I've tried the code but its still not returning any data. The monitored objects are returned but no data for SnapShot Age, Size etc.

Re: Performance Data via Powershell

Posted: Jan 31, 2019 10:15 am
by wishr
Hi Michael,

It definitely works. Could you please explain in details what you are doing and share a few screenshots?

Thanks