Get CM Containers

· sccm powershell

I may sometimes refer to folders as containers and the items inside of them as nodes. It is important to understand that when you create a folder in SCCM it is not really a folder. What you are actually interacting with is a CM Object. What are CM Objects? You can read the Microsoft documentation here CM Objects. But the best TL:DR I can give is that they are Instances of CM specific WMI classes. So when browsing the PSDrive you created and you run Get-ChildItem ABC:\DeviceCollection it is returning a list of all containers at the root of Device Collections, which are the WMI classes for Device Collections. Take a look at the example output below. Notice that multiple containers are returned (more than I have shown here).

PS ABC:\> Get-ChildItem .\DeviceCollection

PSPath                : AdminUI.PS.Provider\CMSite::siteserver.contoso.com\DeviceCollection
PSParentPath          : AdminUI.PS.Provider\CMSite::siteserver.contoso.com
PSChildName           : DeviceCollection
PSDrive               : ABC
PSProvider            : AdminUI.PS.Provider\CMSite
PSIsContainer         : True
SmsProviderObjectPath : SMS_ObjectContainerNode.ContainerNodeID=2
ContainerNodeID       : 2
FolderFlags           : 0
FolderGuid            : 8D4A816D-E5B5-44D0-8D3B-ED3BDBE42CDE
IsEmpty               : False
Name                  : All Systems
ObjectType            : 5000
ObjectTypeName        : SMS_Collection_Device
ParentContainerNodeID : 0
SearchFolder          : False
SearchString          :
SourceSite            : ABC

PSPath                : AdminUI.PS.Provider\CMSite::siteserver.contoso.com\DeviceCollection
PSParentPath          : AdminUI.PS.Provider\CMSite::siteserver.contoso.com
PSChildName           : DeviceCollection
PSDrive               : ABC
PSProvider            : AdminUI.PS.Provider\CMSite
PSIsContainer         : True
SmsProviderObjectPath : SMS_ObjectContainerNode.ContainerNodeID=40
ContainerNodeID       : 40
FolderFlags           : 0
FolderGuid            : FC17345A-AEED-41F2-ABF0-4B9854DCE19D
IsEmpty               : False
Name                  : All Unknown Computers
ObjectType            : 5000
ObjectTypeName        : SMS_Collection_Device
ParentContainerNodeID : 0
SearchFolder          : False
SearchString          :
SourceSite            : ABC

Now lets try running Get-ChildItem ABC:\DeviceCollection\Folder1 and Get-Item ABC:\DeviceCollection\Folder1 notice anything different? We can use Get-Item to just return the parent at that location or Get-ChildItem to return all of its children.

You can use this information to get all containers on the site. Not sure what container types are available? Just ls ABC: and it will return all the container types available to you. Tab complete does work when navigating the drive. However it is very very slow to complete. I recommend you enter in the path instead.

Here is a list of available container types as of writing.

PS C:\Users\kassidy> ls ABC:
Application
BootImage
ConfigurationBaseline
ConfigurationItem
DeviceCollection
Driver
DriverPackage
OperatingSystemImage
OperatingSystemInstaller
Package
Query
SoftwareMetering
SoftwareUpdate
TaskSequence
UserCollection
UserStateMigration
VirtualHardDisk
SmsProvider