Getting queue members for SCSM
Many times, we need the information about which objects contain queue members. The following are two ways to find the queue member information using PowerShell:
# Using SMLets $QueueDisplayName = "QueueName" Import-Module SMLets # Class declaration for Group $Class = Get-SCSMClass -Name "System.WorkItemGroup" $Queue = Get-SCSMObject –Class $Class -Filter "DisplayName = '$QueueDisplayName'" $Relation = Get-SCSMRelationshipClass | Where-Object {$_.Source.Class.Name -eq $Queue.ClassName } Get-SCSMRelatedObject $Queue -Relationship $Relation # Using native CMDLETs: $QueueDisplayName = "QueueName" Import-Module 'C:\Program Files\Microsoft System Center\Service Manager 2012\Powershell\System.Center.Service.Manager.psd1' $Queue = Get-SCSMQueue -DisplayName $QueueDisplayName $Relation = Get-SCSMRelationship | Where-Object {$_.Source.Type.Id -eq $Queue.EnterpriseManagementObject.Id } $Queue.GetRelatedObjectsWhereSource($Relation.Id)
The preceding command...