2 min read

Get-ChildItem and Configuration Manager PowerShell Provider

Get-ChildItem and Configuration Manager PowerShell Provider
Get-ChildItem and Configuration Manager

This week I had the opportunity to speak at the Midwest Management Summit. This year I had two different sessions together with Ryan and Mike. With Ryan, we talked about automation capabilities in Configuration Manager.

Get-ChildItem is one of the cmdlets that you have used in PowerShell. On the file system Get-ChildItem prints out files and folders.

If you run the same cmdlet against the certificate store, it prints out the certificates, etc. If you run the Get-Childitem cmdlet inside the Configuration Manager PowerShell provider. In that case, it only prints out the admin console folders but not the objects within that folder.

Get-ChildItem output from Configuration Manager

Now you may have a question how can I get applications, collections or packages from a specific folder? If you are using folders like me, you may need to change objects under a particular folder and not all the objects.

Luckily we have two different workarounds, and in both cases, we need to retrieve the objects directly through WMI using WMI cmdlets in PowerShell. So let’s take a closer look at how to do that.

Here is the sample folder structure.

In this case, we have two applications under the Defender folder. In a production environment, you may have multiple objects under one folder. However, for demo purposes, we keep this simple.

So the first step for us is to identify the ContainerNodeID value. ContainerNodeIDis the unique folder ID. To do that, we need to use the following command:

Get-ChildItem PS1:\Application | Select-Object -Property Name,ContainerNodeID,ObjectType

This command returns the following output:

Folder Information from Configuration Manager

From this output, we need to copy out the ContainerNodeID property value, and we will use that in a WMI query.

Change the FolderID and SiteCode variable values and then execute. This code block should produce the following output:

Application Names from different folders


Get-ChildItem behaves differently in Configuration Manager PowerShell Provider. Luckily we can get all the information from the WMI directly and work around this shortcoming.