Which groups is a particular computer member of?


Given that groups are used for role based security, overrides, reports, and some other features, it might be pretty interesting to know what groups is a particular computer member of. Attached is a sample script that dumps the list of groups that a particular computer is a member of.


Steps to run the script:


1 – Save the script file


2 – Open the OpsMgr command shell


3 – Run the following: C:\GetContainingGroups.ps1 -computerFQDN:’server1.contoso.com’


 

GetContainingGroups.zip

Comments (7)

  1. Anonymous says:

    Boris Yanushpolsky has written a nice PS script to know what groups a server is member of. Nice work

  2. This script fails and complains that any server name I enter does not have a path. And in truth when I look at Computers under monitoring they indeed do not have a path.

    Get-RelationshipClass : The ‘Path’ parameter is empty or the required provider l

    cation is not set."

    At C:testGetContainingGroups.ps1:5 char:40

    • $containmentRel = Get-RelationshipClass  <<<< -name:’Microsoft.SystemCenter.In

    tanceGroupContainsEntities’

    Get-MonitoringClass : The ‘Path’ parameter is empty or the required provider loc

    tion is not set."

    At C:testGetContainingGroups.ps1:7 char:37

    • $computerClass = Get-MonitoringClass  <<<< -name:"Microsoft.Windows.Computer"

    Get-MonitoringObject : Cannot bind argument to parameter ‘MonitoringClass’ becau

    e it is null.

    At C:testGetContainingGroups.ps1:11 char:51

    • $computer = Get-MonitoringObject -monitoringClass:$ <<<< computerClass -criter

    a:$criteria

    You cannot call a method on a null-valued expression.

    At C:testGetContainingGroups.ps1:13 char:72

    • $relatedObjects = $computer.GetMonitoringRelationshipObjectsWhereTarget( <<<<

    containmentRel,[Microsoft.EnterpriseManagement.Configuration.DerivedClassTravers

    lDepth]::Recursive,[Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recur

    ive)

  3. borisyan says:

    The reason the script is failing is that you ar switching to the FileSystem provider from the OpsMgr provider. There is no need to navigate to C:. All you need to do is just put in the full path to the PS1 file. In other words, dont do "CD C:"

  4. Anonymous says:

    Check out Boris Yanushpolsky&#39;s blog ( http://blogs.msdn.com/boris_yanushpolsky ). Boris is an SCOM

  5. Anonymous says:

    &#160; Voici une liste de liens trés pratique sur tous les sujets SCOM , installation , configuration…