Microsoft have released a new version of the ContentLibraryCleanup tool for System Center Configuration Manager in the latest Technical Preview release (TP1701). By upgrading your Technical Preview release to version 1701 you can start testing the new features of the tool today.
Some of these new features were requested on UserVoice, a forum where people can ask for changes to Configuration Manager (and other products), and then get others to vote their idea up, and if enough interest is seen, Microsoft Product Group take note and hopefully implement the idea. If you haven’t started using UserVoice yet, I highly recommend it, it’s the best way to give feedback about changes you’d like to see in a product.
About the tool
This tool first surfaced in Technical Preview 1612. It’s designed to find content that is broken in one form or another on your distribution points (for whatever reason) and to alert you, or to free up space by deleting that broken content. It was designed to be cautious, if it doesn’t know exactly what is going on it will quit rather than accidentally delete files.
Note: The tool is currently in Technical Preview so avoid running it in a Production environment.
You can run the tool from the Primary site, or if speed is important, run it from the distribution point you are targeting. In fact, you can run the tool from anywhere that can do remote WMI calls to the provider/Distribution Point and SMB calls to the Distribution Point.
It can be found in the following location (after you’ve installed the latest Technical Preview release), where <driveletter> is the drive letter that you installed ConfigMgr on,
<driveletter>\Program Files\Microsoft Configuration Manager\cd.latest\SMSSETUP\TOOLS\ContentLibraryCleanup
Note that you’ll need appropriate access to the cd.latest folder, so press Continue in the UAC prompt.
What switches does it use ?
By opening that location with a command prompt and typing the following command:
you can see the following output:
Usage: ContentLibraryCleanup.exe [/delete] [/q] /dp <Distribution Point FQDN> [/
ps <Primary Site FQDN> /sc <Primary Site Code>] [/log <log file directory>]
/delete (optional) — delete the content, do not print what would be deleted.
/q (optional) — run in quiet mode. Suppress all prompts (assuming delete mode) and do not open log file automatically.
/dp <Distribution Point FQDN> (required) — the FQDN of the target distribution point.
/ps <Primary Site FQDN> (optional*) — the FQDN of the primary site. *Required if the distribution point is on a secondary site.
/sc <Primary Site Code> (optional*) — the site code of the primary site. *Required if the distribution point is on a secondary site.
/log <log file directory> (optional) — the directory to place log files in. Can be a network share. If not specified, the temp folder is used.
Note: By using the /q switch, this also assumes you answer ‘a’ to deleting all found orphaned content in conjunction with /delete.
Testing the tool
So let’s test it.
Note: Make sure to login as a user with Full Administrative access to the distribution point and with the Full Administrator RBAC role (this version of the tool doesn’t check if you are in an ADSG, so make sure you are explicitly a Full Administrator).
Enter the following command (replace the FQDN in bold with your dp FQDN and replace the log folder location with your chosen location), this command will run the tool in What-If mode which doesn’t actually delete anything:
ContentLibraryCleanup.exe /dp cm02.windowsnoob.lab.local /log d:\ContentLibraryCleanupLogs
when prompted about what-if, answer y for yes.
Notice that it tells you how much space it would have saved it you had run it in delete mode. Running the tool also automatically opens the logfile in CMTrace
and that log file will give you details about the following
- Orphaned packages
- Packages with invalid contents
- Orphaned files
- Bytes freed if the tool is run in delete mode
Using the /delete switch
Now that you are familiar with the tool it’s time to use it for what it was designed for, so we’ll add the /delete switch.
Note: In the example below, there is NO problem on the distribution point, so no space is available to be freed up.
Enter the following command, notice the /delete switch. Please replace the FQDN in bold with your distribution point FQDN and replace the log folder location with your chosen location:
ContentLibraryCleanup.exe /delete /dp cm02.windowsnoob.lab.local /log d:\ContentLibraryCleanupLogs
answer yes to see the results
and you’ll get a dated log file with the details of what was freed on the dp in question
As there was no problem on this dp, no space was freed.
Deleting Orphaned content
So the above shows what happens when there’s no problem on the dp, but what if there was one or more orphaned files or packages ?
Note: In the example below, there is a problem on the distribution point, so we can free up space.
Let’s see the results of that….in the first check we omit the /delete switch, to see that it correctly identifies the problem, and it does!
next, it opens the log file (which auto-opens)
Next, run the command again but this time add the /delete switch, the red downward pointing arrow points to the orphaned content and prompts you what to do with it…
answering yes to the prompt will delete the orphaned content (or answer a to delete all),
and, now you can see a difference in the log file too…
Hopefully this new improved tool will help you clean up any unwanted content on your distribution points, and it’s a great improvement and proves that UserVoice works !
thanks to Brandon @ Microsoft for answering my questions !