kmeyler
Consultant

The OpsMgr Command Shell

Analysis
Feb 21, 20082 mins

The Command Shell is an Operations Manager specific implementation of PowerShell. PowerShell of course is Microsoft’s extensible command line interface and scripting language, available for Windows XP SP2, Windows Server 2003, Windows Vista, and part of Windows Server 2008.

The beauty of PowerShell is that it can access data in different data stores via providers, using the same syntax. PowerShell also has a hosting mechanism allowing the runtime to be imbedded inside other applications. This enables those applications to utilize PowerShell’s functionality for performing operations, while using a superset with cmdlets specific to each application. These applications include Exchange 2007, SQL Server 2008, Operations Manager 2007 and other System Center applications including Virtual Machine Manager and Data Protection Manager.

How does this work for OpsMgr? You invoke the Command Shell either by going through the Start menu (Start -> System Center Operations Manager 2007 -> Command Shell) which invokes PowerShell while loading the Operations Manager extensions.

Using the Command Shell you can use the get-momcommand cmdlet to get a list of Operations Manager 2007 cmdlets and the get-Help cmdlet to display help for each cmdlet.

For a batch environment, you can load the extensions themselves. The following code initiates a connection to the Root Management Server (RMS) and loads the OpsMgr PowerShell extensions:

param ($ServerName)

add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";

set-location "OperationsManagerMonitoring::";

new-managementGroupConnection -ConnectionString:$ServerName;

set-location $ServerName;

To learn more about PowerShell, start with https://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx. You can also search the web for numerous blogs, articles, and books that cover PowerShell. System Center Operations Manager 2007 Unleashed also includes examples of using PowerShell for OpsMgr administrative tasks. 

kmeyler

Kerrie Meyler, System Center MVP, is an independent consultant with 17+ years of IT experience, including work as a senior technology specialist at Microsoft. Her books include System Center 2012 Operations Manager Unleashed, System Center 2012 Configuration Manager Unleashed (and the System Center 2012 R2 Supplement), System Center 2012 Orchestrator Unleashed, and System Center 2012 Service Manager Unleashed.

More from this author