################################################# # Author: Mike White # Version: 1.0_05.29.2012 ################################################# Function get-dvnSCCMCollectionMember { <# .SYNOPSIS Get computers in collection .DESCRIPTION Gets computers in specified collection .PARAMETER CollName .EXAMPLE get-dvnSCCMCollectionMember ClientDeployment-May24-Dev .NOTES Just a quick way to get computers that are a member of a collection. Todo's: Add other tasks like check AD to make sure account exists. #> # [CmdletBinding(DefaultParameterSetName = '-CollectionInfo')] Param ( # [Parameter(ParameterSetName = '-CollectionName', Mandatory = $false)][Switch]$CollectionByName, # [Parameter(ParameterSetName = '-CollectionID', Mandatory = $false)][Switch]$CollectionByID, [Parameter(Mandatory = $false)]$CollectionID, [Parameter(Mandatory = $false)]$CollectionName ) if ($CollectionName) { # Get a list of collections and find the object to build the collection list. $MyCollection = Get-WmiObject -ComputerName $SCCMServer -Namespace "root\sms\site_$sccmSiteCode" -Class 'SMS_Collection' -filter "name = '$CollectionName'" # $MyCollection = $Collection | Where-Object { $_.Name -eq "$CollectionName" } # Grab the Resource ID of the collection $MyCollectionMembers = Get-WmiObject -ComputerName $SCCMServer -Namespace "root\sms\site_$sccmsiteCode" -Query "select * from SMS_CM_RES_COLL_$($MyCollection.CollectionID)" #Echo member of the collections to screen write-output $MyCollectionMembers | select @{Label='Username';Expression = {($_.SMSID).replace("CORP\","")}},Name #Foreach ($member in $MyCollectionMembers) #{ # # $oldErrCount = $error.Count # $Name = $member.Name.ToString() # $Name # Write-Host $Name # if(Test-Connection -Count 1 $Name -ErrorAction silentlycontinue) # {#Connection Found # $test = Test-Connection -Count 1 $Name | Select-Object Address, IPV4Address # $test # } # Else # { # Write-Verbose "Connection to $Name Failed" -Verbose # #Write-Host $Name # #$Name # } } } elseif ($CollectionID) { Get-WmiObject -computername $SCCMServer -namespace "root\sms\site_$sccmSiteCode" -query "select * from SMS_CM_RES_COLL_$($CollectionID)" | Select name, IsActive, IsClient, IsBlocked } }