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) | select ManagementGroup
get-managementserver | select ManagementGroup -unique
Have fun with PowerShell!
(get-managementGroupConnection).Managementgroup.Name or (get-managementGroupConnection).Managementgroup.Name (if you have multiple connectons) will tell you the MG you are connected TO... which hopefully is cached on the client side already, but I have not done perf testing on it. Try it out.
I can think of a reason about the speed and how these commands are likely implemented:
The first command you suggest is faster because it just gets the FIRST MS that gets returned and looks up one of its properties.
The second is likely slower because (I suppose) it is a wrapper on top of the other one... basically, it still returns ALL the MS's internally, and loops thru them to look up which one is Root, and then return that alone to the user.