Thursday, November 14, 2019

Managing stale Windows 10 user profiles with delprof2 and PDQ Deploy.

A very common problem with Windows 10 in a k12 lab environment, especially now that blazing fast, but less spacious SSDs are becoming more common, is that after a few months of many different students logging into a machine, the drive can fill completely up with old user profiles.

There is a GPO you can set to remove profiles that haven't been used for x amount of days, and there's also a nifty utility out there called "delprof2" that you can use to clean these profiles, but of course there's a catch (more of a bug IMO)..

Both the GPO and delprof2, use the last modified timestamp of the ntuser.dat file to determine how old a profile is.  And for some reason when some Microsoft updates are installed, it modifies the ntuser.dat file in all profiles on the PC (including unused profiles), causing the date stamp to never age past the required time for deletion.  See the post here on Microsoft's tech community site for more details of the problem itself:

https://techcommunity.microsoft.com/t5/Windows-10-deployment/Issue-with-date-modified-for-NTUSER-DAT/m-p/102438

A post a few replies down on that page contains a powershell script that resets the modified date of the ntuser.dat file to the date of the folder that contains it, which allows these tools to do their job.

I decided to leverage this script, along with either the GPO, or in my case, I chose to use delprof2 in conjunction with the ultimate IT tool(s)...PDQ Inventory and Deploy.  I'm sure you could make something similar worth worth other tools also, but this is what I know and use.

Here's how I accomplished it:  (This is all assuming you have a very basic understanding of how pdq packages work.)  If you don't, and you're in the IT business, I suggest you give it a try.  It saves an absurd amount of time, and is well worth the cost if you have a whole bunch of Windows PCs to manage.

I slightly modified the powershell script from the above link, and saved it to a network location (such as your PDQ repository).  Here is my modified version if anyone wants it, along with other relavent links.

The following steps could be combined into the same package, I just made it this way and that's how it got left.

Set up a simple PDQ deploy package that runs the date fix powershell script.  (I'm sure you could paste the script right into the window here instead of calling it this way, I just already had the script saved from testing it outside of deploy so I just pointed to it.)


As a step 2, or in a new package, run 'delprof2.exe /d:30 /q'

/d:30 means delete any profiles not used for the last 30 or more days, and /q is quiet mode, which PDQ requires, since it runs as a different user than who is logged in.  Step 1 just calls the first package I created.


I will be scheduling this Deploy package to run at regular intervals on our student labs.  And that should do it.