Freigeben über


OpsMgr 2012 PowerShell: Getting Oriented

Quick Reference

As some of you may already know the PowerShell support in OpsMgr 2012 changed significantly from OpsMgr 2007 R2. For starters, the cmdlets are no longer an optional part of the UI install.  It used to be you could select whether or not to install the PowerShell interface, when you installed the operations console, but now it installs automatically, every time you install the UI.

Secondly, and more importantly, the implementation is totally different.  This is good in that it was built from scratch for PowerShell 2.0 (and beyond) and it does away with a few of the bad practices that existed in OpsMgr 2007 R2 (i.e. the navigational provider for the instance space).  It is also bad in that much of what we had in the past will not work and in some important ways the behavior has changed for the worse.

In my upcoming posts I will explore the OpsMgr 2012 PowerShell module and share common ways for using the cmdlets.

So let’s get started…

The first step is to import the module.  If you’ve already got PowerShell 3.0 installed then you can skip this step, but let’s cover it for completeness
sake.  Open an instance of PowerShell, and run the following:

import-module operationsmanager

If you get no output and you just see the prompt on the next
line, then everything worked and now the module is loaded.  From there run the following command to see
the “about_” help topics that ship with the module:

get-help OpsMgr

For getting started, I’d recommend reviewing at least the
following:

get-help about_OpsMgr_WhatsNew | moreget-help about_OpsMgr_Cmdlet_Names | more

Note:  As the What’s New topic points out, everything in this module will only work with OpsMgr 2012.  If you want to programmatically work with 2007 R2 then the What’s New topic walks you through how to do that and you’ll need to use your old scripts and one-liners to do it.  All the more reason to get to one version quickly :).

Next, get the full list of cmdlets that are included with the OperationsManager module by running the following:

get-command -module operationsmanager | more

If you find a cmdlet that is of interest to you and you want to learn more about what it does and how to use it, you can go any of the following

get-help <cmdletName> -detailed | more
This will provide the help content for the cmdlet, including the examples.

get-help <cmdletName> -full | more
This will provide the verbose details on the parameters that are available for the cmdlet.

<cmdletName> | Get-Member
This will show you the possible type(s) that a given cmdlet can return and what the methods and properties are on those types.  This is especially useful for figuring out what you can use in pipelining cmdlets together.

In the next post I’ll write about the new way in which the OpsMgr 2012 module handles connections.

Cheers until then,
Cory