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″]