Thursday, March 22, 2018

Content Library Cleanup Tool explained

Just to expand on my previous post, here are some more of my findings on the Content Library Cleanup Tool.


  • Don't be afraid to delete content.  The content you are deleting with this tool is either invalid or orphaned, and is not the same as the content in your production environment.  It is perfectly safe to delete all content the tool finds in its scan - your DP will still contain the original content afterwards.
  • The tool may glitch every once in awhile.  I've seen a few times where the tool will keep showing "Analyzing local files... 99.92% complete" or close to that while appearing to still scan for content.  Pay attention to the prompts that come up between these same messages - you can press 'a' or 'y' on a separate line (yes, while it's still "scanning" at this same percentage repeatedly) and see if it accepts your input - if it does, it's in a buggy loop despite it still being able to process.  You can optionally check the free space of the drive the content is stored on to verify it's still being cleaned, or you can close the tool and re-run it again, your choice.
  • Be patient.  Occasionally you may notice the tool seems to 'lock up' at certain points.  I have yet to see the tool completely lock up without reason, so just be patient since whatever it's working on, chances are there's a lot of it to delete.  This is especially true of Endpoint Protection Definition Updates or any other content that gets refreshed consistently on the DP.
  • Troubleshooting. In case you ever receive the 'package is not fully installed' error, check the PackageID to validate if the content is being actively distributed to the DP.  If it isn't, the next step is to remove the content from the DP.  After doing so, run the tool again.  Then after the tool successfully runs, be sure to re-distribute the content you removed previously.  There are other errors that can happen with the tool indicating missing content, however, the tool can be re-ran to bypass these errors.
  • The tool may appear to delete 'too much'.  Depending on your environment/amount of content, the tool can easily free up hundreds of gigs of space on the content store's drive.  This is normal/expected behavior.

Monday, March 19, 2018

Scripting the automation of the Content Library Cleanup Tool

As of SCCM 1702's release, the Content Library Cleanup Tool is a nifty addition to cleanup your distribution points painlessly and effectively.  Since it requires command line parameters to run, I have created scripts to run the tool easier without having to remember the parameters.  There are two modes, 'what-if' and 'delete' modes for the tool, and I've created batch scripts for each mode and named them respectively.

For 'delete' mode, here is the batch script ("CLCT-Delete.cmd"):
@echo off
set /p dp="Please specify the DP hostname.  Hit Enter for %COMPUTERNAME%: "
if [%dp%] == [] ( goto default ) else (
"%~dp0ContentLibraryCleanup.exe" /dp %dp% /delete /log "%~dp0Logs\%dp%"
goto exit
)
:default
"%~dp0ContentLibraryCleanup.exe" /dp %COMPUTERNAME%.domain.com /delete /log "%~dp0Logs\%COMPUTERNAME%"
:exit
pause
exit 

For 'what-if' mode, here is the script ("CLCT-WhatIf.cmd"):

@echo off
setlocal EnableDelayedExpansion
set /p dp="Please specify the DP hostname.  Hit Enter for %COMPUTERNAME%: "
if [%dp%] == [] ( goto default ) else (
"%~dp0ContentLibraryCleanup.exe" /dp %dp% /log "%~dp0Logs\%dp%"
goto exit
)
:default
"%~dp0ContentLibraryCleanup.exe" /dp %COMPUTERNAME%.domain.com /log "%~dp0Logs\%COMPUTERNAME%"
:exit
pause
exit 


The script assumes "ContentLibraryCleanup.exe" is in the same folder as the script.  It will prompt for the hostname of the distribution point, and if none is entered, uses the current machine's hsotname as default.  It then writes everything to a log file in Logs\<hostname> folder as well (and opens it automatically when done).

Note: The Tool will crash if any content is currently being distributed to the DP (and it will do this after it's processed all content, which takes awhile).  Refer to the link above for more details if needed.

Wednesday, March 14, 2018

Fixing the "Task Sequence is locked" issue

Sometimes you'll edit a Task Sequence and either the console crashes, site goes down, or the TS is in use by another SCCM admin (but may not actually be in use anymore).


The normal solution is to wait 30 minutes after the TS is no longer in use and the lock will clear itself.  This doesn't always happen, and when it doesn't, this SQL query may prove to be useful:

SELECT * FROM SEDO_LockState WHERE AssignedUser = 'domain\username'
This query assumes you know the domain\username of the offending user who's no longer editing the TS.  If you don't know which user is, you can just run a simpler version - but be prepared to sift through a lot more info:

SELECT * FROM SEDO_LockState

Once you find the culprit record, run the query below to delete it:

DELETE FROM SEDO.LockState where ID = '555'
Replace 555 above with the actual number returned in the ID column of the record.

NOTE: I take no responsibility for deleted records due to misused queries.  Use at your own risk.  😀