Command Shell Examples
Useful SQL Queries
April, 2009 - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

April, 2009

  • Agent Failover Status

    Here is a script that will output agent failover status. Simply copy the script below into the Command Shell on any Management Server, including the Root Management Server.  The results will show you a list of agents currently connected to that Management...
  • All disk sizes (GB)

    /*Get each logical disk size, for each agent computer, by OS version. This helps in calculating the Logical Disk Free Space Monitor from my earlier post .  You can copy results into Excel, sort by system and non-system drives, and perform an average...
  • Get Alert History by Alert Name

    get-alert | where {$_.name -match " Alert Name "} | get-AlertHistory | select Time* command shell main menu
  • Get Failover MS List for Agent Computer

    This will return the list of Failover Management Servers for specified agent. get-agent | where {$_.computername -eq " netbios computername "} | Get-FailoverManagementServer | select computername command shell main menu
  • Top 10 Events

    This will return the top ten events collected. FYI – Given the sheer number of events collected and stored in the OperationsManager database, this query may take a minute to return results. $array = @();foreach ($number in Get-Event | foreach-object ...
  • Switch to another MG in Command Shell session

    If you have multiple Management Groups, this can be handy to switch between them while in the same Command Shell session. Always be aware of which Management Group you’re connected to while in the Command Shell! This example assumes your session is...
  • Operations Manager 2007 SQL Queries

    Sharing this list of random SQL queries I have found useful on different occasions. Refer to report dataset samples page for SQL queries you can use for custom reporting needs. Updated: 08-05-2011 OperationsManager OperationsManagerDW...
  • All groups and their contained instances

    SELECT     SourceMonitoringObjectDisplayName AS 'Group', TargetMonitoringObjectDisplayName AS 'Member' FROM         RelationshipGenericView WHERE     (SourceMonitoringObjectDisplayName...
  • All groups

    SELECT     ManagedEntityGenericView.DisplayName, ManagedEntityGenericView.FullName FROM         ManagedEntityGenericView INNER JOIN                          ...
  • What does this task target?

    This will return which [typed] class the specified task will run against. foreach ($targetId in get-task | where {$_.displayname -match " task name "} | foreach-object {$_.get_target().id.tostring()}) {get-monitoringclass | where {$_.id -eq...
  • Return discoveries running on specific interval

    Got a new one today.  HTH. Foreach ($discovery in (get-discovery | foreach-object {$_.DataSource}))     {     if ($discovery.Configuration -match "IntervalSeconds> seconds <")        ...
  • Exclude Drive from Logical Disk Free Space Monitoring: Part 1

    Since I just wrote an article on how to use the Logical Disk Free Space monitor , I figured this would be a nice compliment to that post.  I highly recommend reading that article to get an understanding of this monitor before moving forward with...
  • How to measure Operations Manager database performance

    In order to make any kind of performance tuning recommendations, it is first necessary to capture a baseline of normal operating conditions. What I’d like to demonstrate in this post is how to measure the performance of your Operations Manager database...
  • Logical Disk Free Space Monitor

    Throughout my years working with MOM and Operations Manager 2007, periodically I hear complaints about Operations Manager not alerting on low disk space conditions, or that administrators are receiving false alerts. Just about every time I've been called...
  • Command Shell: Be careful with Date-Time criteria and calculations

    Nathan left a comment on one of my posts the other day. See thread:  Is alert grooming working? Well, Nathan helped me find a problem with my script.  The problem was the Date-Time criteria I was using for my calculations to verify whether or...