| Maxim's profileOpsMgr 2007 NotesBlogLists | Help |
|
|
February 10 Determine a computer’s group with PowershellIf your OpsMgr environment has a complex group structure with a huge amount of groups and subgroups, it’s going to be rather difficult to determine a group membership of the particular computer. Here is a small powershell script that allows you to find out a computer’s membership very quickly. Usage is clear, just pass a computer FQDN as a parameter. >C:\GetGroupsThatContainComputer.ps1 <computerFQDN> like >C:\GetGroupsThatContainComputer.ps1 hydra.contoso.com As result you will get a list of all groups that contain computer hydra.contoso.com Here is full source code of GetGroupsThatContainComputer.ps1 file:
param($computerFQDN) function GetGroupNames($computerFQDN) $computerClass = Get-MonitoringClass -name:"Microsoft.Windows.Computer" $criteria = [string]::Format("PrincipalName = '{0}'",$computerFQDN) $computer = Get-MonitoringObject -monitoringClass:$computerClass -criteria:$criteria $relatedObjects = $computer.GetMonitoringRelationshipObjectsWhereTarget($containmentRel,[Microsoft.EnterpriseManagement.Configuration.DerivedClassTraversalDepth]::Recursive,[Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recursive) foreach($group in $relatedObjects) } GetGroupNames $computerFQDN
Enjoy! This posting is provided AS IS with no warranties. Use it at your own risk. TrackbacksThe trackback URL for this entry is: http://maxim-ua.spaces.live.com/blog/cns!9C26C04B756ADA31!138.trak Weblogs that reference this entry
|
|
|