Get SCCM Collection Information from ID

I have been working with PowerShell and SCCM for the last 4-5 years and I have built some nice to have Functions that I often use. If you ask me 🙂

Now 50% of all readers will say “You don’t need to use WMI” or “You should connect in another way to WMI”.
In a new environment with SCCM 2012 and with PowerShell 3.0 or 4.0 you are probably right 🙂

I have been making tools and administered SCCM 2007 environments most of the time and with client computers with PowerShell 2.0. So my code will work on SCCM 2007 and SCCM 2012 environments and remote from Windows 7/8x.

This is the first one that I will publish here.

The function will show all the information from SCCM about a collection based on the Collection ID.

I wrote this one because that I some times had the Collection ID but not the name.

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<#

.SYNOPSIS

Get Collection Information from Collection ID

.DESCRIPTION

A detailed description of the Get-SCCMCollectionInfoFromID function.

.EXAMPLE

Get-SMSCollectionInfoFromID

.EXAMPLE

(Get-SCCMCollectionInfoFromID).Name

.EXAMPLE

Get-SMSCollectionInfoFromID | gm

.NOTES Created by: Fredrik Wall

Blog: http://www.fredrikwall.se

#>

functionGet-SCCMCollectionInfoFromID

{

[CmdletBinding()]

param(

[Parameter(Mandatory=$True)]

$SiteServer,

[Parameter(Mandatory=$True)]

$SiteCode,

[Parameter(Mandatory=$True)]

$CollectionID

)

$Collection=Get-WmiObject-Namespace"root\SMS\Site_$SiteCode"-Query"select * from SMS_Collection Where SMS_Collection.CollectionID='$CollectionID'"-computername$SiteServer