Export (0) Print
Expand All

Using the Operations Manager Command Shell

Updated: May 22, 2009

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1

The Microsoft System Center Operations Manager 2007 command shell is installed with the Operations Manager console; it provides a command-line environment and task-based scripting technology that you can use to automate most Operations Manager administrative tasks.

How the Operations Manager Command Shell Works

The Operations Manager command shell is built on Windows PowerShell. The Operations Manager command shell extends the Windows command shell with over 80 additional small utility programs, called cmdlets, which can either be run directly from the command shell prompt or called from within a batch file or script. Cmdlets can be used by themselves, or they can be combined with other cmdlets to perform complex administrative tasks. Unlike traditional command-line environments that work by returning text results to the end user or routing (“piping”) text to different command-line utilities, PowerShell manipulates Microsoft .NET Framework objects directly. This provides a more robust and efficient mechanism for interacting with the system.

This topic serves as an overview to the Operations Manager command shell. To learn more about PowerShell, see the Windows PowerShell 1.0 Documentation Pack (http://go.microsoft.com/fwlink/?LinkID=128867).

Using the Operations Manager Command Shell

In this section, we will walk through some common tasks with the Operations Manager 2007 command shell.

Launch the Operations Manager 2007 command shell and list the available commands

  1. To launch the Operations Manager 2007 command shell, click Start, select Programs, and then select Command Shell from the System Center Operations Manager 2007 menu.

  2. From the command shell prompt, type Get-OperationsManagerCommand to retrieve a list of all of the available Operations Manager 2007 cmdlets.

  3. To see help for any specific cmdlet, type get-help followed by the name of the cmdlet. For example, type

    get-help Get-State to retrieve help information about the Get-State cmdlet.

Command Shell Usage Examples

This section contains a number of examples of command shell usage. Enter the commands at a command shell prompt, or use them in a batch file or script.

ImportantImportant
The –name and –criteria parameters that are used by the command shell are case sensitive.

Export management packs

  1. To export a management pack, run the following command:

    get-managementPack -name Microsoft.SQLServer.2005.Monitoring | export-managementPack -path c:\mp
    
  2. To export all management packs in a management group, run the following command:

    get-managementPack | export-managementPack -path c:\mp
    
  3. To export all management packs that contain a specified string in their name, run the following command:

    get-managementPack | where {$_.name –match 'SQL'}
    

Examine management pack elements

  1. To list all rules by management pack, run the following command:

    get-rule | select @{name="MP";expression={foreach-Object {$_.GetManagementPack().DisplayName}}},DisplayName | sort mp,displayName
    
  2. To list all monitors in a specific management pack, run the following command:

    (get-managementPack -name Microsoft.SQLServer.2005.Monitoring) | get-monitor | sort displayName | ft displayName
    
  3. To list all disabled discoveries, run the following command:

    get-discovery | where {$_.enabled -eq 'false'} | ft displayName
    

View Alert Data

  1. To view all unresolved alerts, run the following command:

    get-alert -criteria "ResolutionState <> 255"
    
  2. To view all alerts grouped by severity and name, run the following command:

    get-alert -criteria "ResolutionState <> 255" | sort severity,name | group severity,name
    
  3. To resolve all alerts generated by rules, run the following command:

    get-alert -criteria "ResolutionState <> 255 and IsMonitorAlert = 'False'" | resolve-Alert
    

Retrieve Performance Data

  1. The example below extracts processor utilization data for all computers for the month of October 2008 to a comma-delimited file:

    
    > $startTime = get-date '10/1/2008'
    > $endTime = get-date '10/31/2008'
    > $pc = get-performanceCounter -criteria: "ObjectName='Processor' and 
    CounterName='% Processor Time' and MonitoringObjectPath='web.contoso.com'"
    > get-performanceCounterValue -startTime $startTime -endTime $endTime -
    performanceCounter $pc | export-csv c:\scripts\mom\perf.csv
    
    

Additional Resources

For more information about Windows PowerShell, consult the following resources:

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft