Getting the OpsMgr ManagementGroup name with PowerShell (fast)

Update: Found out that command did not worked when there is only one Management Server.

Today I was trying to create some PowerShell scripts for the use with PowerShellASP from /n Software and wanted to find the name of the OpsMgr Management Group.

Because I was not sure which Cmdlet could give me this info I tried several Cmdlets and the first two I found where get-rootmanagement server and get-managementserver. Both Cmdlets returned info about the Management Group. There could be more Cmdlets that give that info but I found that there is a great time difference between the two Cmdlets. (tested in an OpsMgr 2007 SP1 environment). No idea why but if you want to get the Management Group info fast, better use the next command:

(get-managementserver)[0] | select ManagementGroup

get-managementserver | select ManagementGroup -unique 

image

 

Have fun with PowerShell!