Command Shell Examples
Useful SQL Queries
Get last value sampled by performance collection rule - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

Get last value sampled by performance collection rule

Get last value sampled by performance collection rule

  • Comments 2
  • Likes

I took some time today to find something new to add to my Command Shell examples table.  I thought this one was kind of neat.  For those of you who like to use the CLI, this is an alternative to get quick info as opposed to using the console.

This example in particular returns the LogicalDisk \ % Free Space counter sample for all J: drives.  Just replace the red parameters to return values of any counter that is being collected by SCOM.  Beware of word wrap, as this is a one-liner.  Also, those are all single quotes in the criteria selection.

 

Get-PerformanceCounter -Criteria 'ObjectName = ''LogicalDisk'' and CounterName = ''% Free Space'' and InstanceName = ''J:''' | Select MonitoringObjectPath, MonitoringObjectDisplayName, @{Name="Value";Expression={Foreach-Object {$_.GetValues((Get-Date).AddDays(-1),(Get-Date)) | Select -Last 1}}}

 

Command Shell Main Menu

I do not moderate this blog anymore. If you have a question regarding this post, send me a message.

Comments
  • Awesome Jonathan, this will help a lot do to more custom queries.

    Regards,

  • I was on the same track, Cleber.  Think of the possibilities.  I sense another post coming from you :)