One Provider to Rule Them All!

Along with a healthy dose of Cmdlets, the Operations Manager snapin (aka "Command Shell") includes a PowerShell Provider that allows you to manage one or more Management Groups at the same time. 

To start, create a connection to each Management Group you want to manage. For example...

# Connect directly to a Management Group

New-ManagementGroupConnection mg1.redmond.corp.microsoft.com

or

# Connect to a Management Group that is a child tier of the current Management Group.

$creds = Get-Credential

Get-Tier | where {...} | New-ManagementGroupConnection -Credential:$creds

Next, move to the root of the Monitoring drive so you can see the connections you have created.

Monitoring:\...\> cd \

Monitoring:\> dir

That's it!

>>All operations from the root of the Monitoring drive will affect all connected Management Groups.<<

 

In case you are wondering how useful this is here are a few examples.

1. Find a Monitoring Object across all of your Management Groups.

dir -R | where {$_.Name -match "foobar"}

2. Install a management pack across all connected Management Groups.

Install-ManagementPack C:\ManagementPacks\CustomMP.xml

3. Get alerts across all connected Management Groups

Get-Alert ...

4. Get events across all connected Management Groups.

Get-Event ...

and so on...

 

Most GET Cmdlets work the same way even though they are spanning multiple connections. Cmdlets that affect change may not work as expected and will usually fail because they are passed an object that is unique to one Management Group.

BE CAREFUL!  Objects like ManagementPacks, Classes and Relationship Classes which are unique within one Management Group have the same identifier across all Management Groups and therefore can be inadvertently manipulated across multiple Management Groups when multiple connections exist.

BE VERY CAREFUL! More than one connection to the same Management Group can be created with a different name making it is very easy to inadvertently run the same command against the same Management Group multiple times.