Unleash the power of System Center for vSphere and Hyper-V | Veeam Task Manager for Hyper-V
Post Reply
Michael.Aksoy
Lurker
Posts: 2
Liked: never
Joined: Jan 30, 2019 2:15 am
Contact:

Performance Data via Powershell

Post by Michael.Aksoy » Jan 30, 2019 2:20 am

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.

wishr
Veeam Software
Posts: 484
Liked: 53 times
Joined: Aug 07, 2018 3:11 pm
Full Name: Fedor Maslov
Contact:

Re: Performance Data via Powershell

Post by wishr » Jan 30, 2019 2:34 pm

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

Michael.Aksoy
Lurker
Posts: 2
Liked: never
Joined: Jan 30, 2019 2:15 am
Contact:

Re: Performance Data via Powershell

Post by Michael.Aksoy » Jan 31, 2019 1:41 am

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.

wishr
Veeam Software
Posts: 484
Liked: 53 times
Joined: Aug 07, 2018 3:11 pm
Full Name: Fedor Maslov
Contact:

Re: Performance Data via Powershell

Post by wishr » Jan 31, 2019 10:15 am

Hi Michael,

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

Thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests