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.
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
3. Select Query tab and execute the following WQL query:
Select ContainerNodeID,Name,ObjectType from SMS_ObjectContainerNode
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
$FolderID = 16777224 # Use the WMI tool to get the FolderID $CollectionsInSpecficFolder = Get-WmiObject -Namespace "ROOT\SMS\Site_PS1" ` -Query "select * from SMS_Collection where CollectionID is in(select InstanceKey from SMS_ObjectContainerItem where ObjectType='5000' and ContainerNodeID='$FolderID') and CollectionType='2'" $CollectionsInSpecficFolder.Name
5. Execute the following code and it should list all the Collection Names in OSD folder.
As you see you can query the folder objects only with one query and no need for multiple queries.
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!
Is developer mode the same thing as debug view?
http://msdn.microsoft.com/en-us/library/hh948469.aspx
Hi,
Yes, it was the Debug view not the Developer view 🙂 – /sms:debugview=1
Best,
Kaido
Great info!
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