The EASY WAY – List objects in specific folder in Configuration Manager 2012 with PowerShell

Last week I saw one blog post how to list specific folder objects and I believe that actually there is much easier way to list the objects in specific folder. First we need to figure out the ContainerNodeID which is the folder unique ID.

We have several ways to find out the folder unique ID, for example we can run the ConfigMgr Admin console in developer mode or we can use a WMI tool. There are different WMI tools that you can find from the internet or you can simple use the WBEMTEST tool also which is already built-in in Windows. In this case I´m using our Coretech WMI and PowerShell Explorer tool.

So let’s assume that you want to modify collections in OSD folder. In this case I have two collections in OSD folder.

clip_image001

clip_image002

1. Run the Coretech WMI and PowerShell Explorer tool and connect to ROOT\SMS\Site_PS1 namespace.

2. Type into Filter textbox ObjectCon and select SMS_ObjectContainerNode WMI class

clip_image003

3. Select Query tab and execute the following WQL query:

Select ContainerNodeID,Name,ObjectType from SMS_ObjectContainerNode

clip_image004

In this output you should see the folder name and the unique ID (ContainerNodeID). Object type 5000 means a Device Collection. You can check additional values from here. Write down the ContainerNodeID property value and then open PowerShell ISE.

4. Write the following code

5. Execute the following code and it should list all the Collection Names in OSD folder.

clip_image005

As you see you can query the folder objects only with one query and no need for multiple queries.

About the Author:

Kaido Järvemets
Configuration Manager MVP

5 Comments

  1. Kevin Johnston March 24, 2014 at 21:28 - Reply

    Thanks for the article, Kaido. I’m curious: How does one “run the ConfigMgr Admin console in developer mode”? Is it a parameter that can added to the run line of the console shortcut? Thanks!

  2. Kevin Johnston March 24, 2014 at 22:09 - Reply

    Is developer mode the same thing as debug view?

    http://msdn.microsoft.com/en-us/library/hh948469.aspx

    • Kaido Järvemets
      Kaido Järvemets March 25, 2014 at 9:41 - Reply

      Hi,

      Yes, it was the Debug view not the Developer view 🙂 – /sms:debugview=1

      Best,
      Kaido

  3. Rich November 16, 2014 at 12:00 - Reply

    Great info!

  4. Christian Cools May 31, 2016 at 20:46 - Reply

    Hi Kaido,

    Strange but probably explainable (RBA perhaps?).
    I used the debug view option as described in your post, but then the SMS_ObjectContainerNode class isn’t part of the list of classes the Tools node in the console provides. But a query to this class is possible, and I got the instances I needed. Not gonna worry too much about it, the above method worked fine for me, but don’t yet understand why the class isn’t listed in the first place.

    Oh hell, who cares 🙂 thanks for this post, loved it!

    Regards
    Chris Cools

Leave A Comment