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.
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jan 30, 2019 2:15 am
- Contact:
-
- Veteran
- Posts: 3077
- Liked: 455 times
- Joined: Aug 07, 2018 3:11 pm
- Full Name: Fedor Maslov
- Contact:
Re: Performance Data via Powershell
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:
Please note, the following:
Hope this helps!
Regards,
Fedor
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}}}
- 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.
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}}}
Regards,
Fedor
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jan 30, 2019 2:15 am
- Contact:
Re: Performance Data via Powershell
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.
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.
-
- Veteran
- Posts: 3077
- Liked: 455 times
- Joined: Aug 07, 2018 3:11 pm
- Full Name: Fedor Maslov
- Contact:
Re: Performance Data via Powershell
Hi Michael,
It definitely works. Could you please explain in details what you are doing and share a few screenshots?
Thanks
It definitely works. Could you please explain in details what you are doing and share a few screenshots?
Thanks
Who is online
Users browsing this forum: No registered users and 1 guest