Archive Empty Collections in ConfigMgr

Below is a script that will move empty collections to a particular folder in ConfigMgr. This can be helpful for cleanup and pairing down collections that are no longer needed. It will also write the moves to a log file, including when the collection was moved and where it was moved from. This log is written as a CSV file.

When you download the script, you must change the first three lines. In line one, insert your site code. In line two, type the path to the log file. In line three, input the folder to move the empty collections too. If they’re device collections, it should read like this:

“<site code>:\DeviceCollection\folder1\folder2”

If they’re user collections, it should read like this:

“<site code>:\UserCollection\folder1\folder2”

As written, this script will move collections with a member count of zero. You can modify that if you like by changing the value at the end of line 13:

User Collections

To run against user collections, you also need to modify line 13 to look like this:

$colls = get-cmusercollection | where-object -filterscript {$_.MemberCout -eq “0”}

Limitations

Currently, if you want to run this against user and device collections, you will need two scripts.

This script must be executed from a device with the ConfigMgr console installed.

[download id=”4912″]

Share:

Facebook
Twitter
LinkedIn
Picture of Matt Tinney

Matt Tinney

Professional IT executive & business leader having decades of experience with Microsoft technologies delivering modern-day cloud & security solutions.

Contact Us

=
On Key

More Posts

WME Cybersecurity Briefings No. 028
Cyber Security

WME Security Briefing 27 September 2024

DragonRank SEO Manipulation Campaign Targeting IIS Servers Across Asia and Europe Overview A cyber espionage campaign is targeting IIS servers in several countries across Asia and Europe. The DragonRank campaign emanates from a simplified Chinese-speaking actor and specializes

Click Here to Read Full Article »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=