Poked around the interwebs a while and noticed a lot of scripts had references to 2007 commands that hadn't been updated to 2012. Here's the basic steps taken to get my group of SQL servers. You could perform the same task on pretty much any group in the same manner.
- Open the Operations Manager Shell powershell console
- Type in : Get-SCOMGroup
- Search for the group you want to retrieve members from
- Now type in: $Group = Get-SCOMGroup | where {$_.DisplayName -eq "SQL Computers"} (or insert the group your looking for instead of SQL Computers")
- Next, type in: $Members = $Group.GetRelatedMonitoringObjects()
- Now, you can simply type: $Members
- Or, pipe the command out to a file: $Members | Sort DisplayName | FT DisplayName | out-file C:\Scripts\Servers.txt
It was helpful. Thank you
ReplyDeleteHi There,
ReplyDeleteThanks for the command, It seems to work on 1 specific management group.
But when i enter the 2nd command $Members = $Group.GetRelatedMonitoringObjects()
I get the below error:
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $Members = $Group.GetRelatedMonitoringObjects()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Any idea ?
Ok i found the issue here.
DeleteI was giving the wrong group / incorrect group name in command 1 which caused command 2 to throw that error.
:) Happens all the time
DeleteIf you face error in the last line, either create a C:\Scripts folder or use the following line instead:
ReplyDelete$Members | Sort DisplayName | FT DisplayName | out-file C:\Servers.txt
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete