In our environment we have 5 production management groups (3 for "core" monitoring, 1 for application monitoring and one for connecting to our network monitoring system). Many times I want to be able to quickly run some cmdlet across all of these management groups to do things like the following:
Since I'm also too lazy to be bothered with always having to run the Operations Manager command shell shortcut and then run "New-ManagementGroupConnection" 4 times (I get one connection for free on start-up and have to kick up the others) I decided to add a couple things to my PowerShell profile to simplify this:
Note: For those that may not be familiar with PowerShell profiles check out the about_profiles topic online or by running "get-help about_profiles | more" within PowerShell.
If you want to do this yourself do the following:
So now that you've got a PowerShell session setup with active connections multiple management groups, you do the following to run one or more cmdlets or scripts against those connections: # Move to the root of the Monitoring:\ PSDrive cd monitoring:\
# Use get-childitem to loop through each connection and run a cmdlet against each connection. Pass into the cmdlet the PathName from the connection item get-childitem | foreach-object{<OPSMGR_CMDLET_NAME> <PARAMETERS> $_.PathName }
The following example will loop through each connection and get the management pack object for "Microsoft.SystemCenter.2007" (aka "System Center Core Monitoring" or the OpsMgr MP): get-childitem | foreach-object{Get-ManagementPack -Name Microsoft.SystemCenter.2007 -Path $_.PathName }
I hope that some of you find this as useful as I have and that these tricks save you some time down the road.