Update Device Collection Membership in SCCM Manager 2012 via PowerShell & Limiting Collection Issue

I have different Device Collections for servers in different AD group. One collection called Server Pilot contains a group of pilot servers. I usually deploy security updates to this collection before we deploy updates to production servers. The membership rule is simple which is to query the AD group and put device in the group into this collection.

Today I find there are 2 servers should have SCCM client installed and put into the Pilot collection. I installed the SCCM client and added 2 servers into the AD group and hope the Server Pilot device collection can update. But it didn’t. Then I manually updated it by selecting the device collection, brought the right click menu and clicked Update Membership on SCCM Manager. I found it still did not have the new servers. I saw the Device Collection icon was changed to the icon with a small hourglass meant to wait. I wanted to speed-up the collection membership. Then I find this article

https://www.petervanderwoude.nl/post/update-collection-membership-in-configmgr-2012-via-powershell/

The key is the one line command which can update the device collection instantly:

Invoke-WmiMethod –Path `
“ROOT\SMS\Site_$($SiteCode):SMS_Collection.CollectionId=’$CollectionId'” `
-Name RequestRefresh -ComputerName $SiteServer

For example:

Invoke-WmiMethod `
-Path "ROOT\SMS\Site_$('P04'):SMS_Collection.CollectionId='P040005E'" `
-Name RequestRefresh -ComputerName CGYSCCM01

Nice! It did update the collection instantly which can be told by the Update Time in Summary tab.

But this did not fix my problem. I still did not see 2 new servers. I had to double check the collection settings and finally find the reason – the limiting collection!

There is a limiting collection – “All Windows Server Systems (P02)” in the properties. Don’t fool by the name, somebody created this collection but not contains all windows servers like the two new servers! Since the limit collection did not has the two device, the Pilot collection did not has them either no matter how I updated it. I had to change the limiting collection to All Systems – means no limit. Then I used the same PowerShell command to update the All Windows Server System collection and update the Server Pilot collection again. Problem solved!

Leave a Reply

Your email address will not be published. Required fields are marked *