Copy to

Cleanup User Profiles

Delete all old user profiles


This agent procedure will delete all users profiles but the current logged in user and special users than have not been used for over 90 days.
The agent procedure uses a tool called Delprof2 in order to perform the cleanup.
You can find more information here.
You may also edit the first line of the procedure to change the age of the stale profiles you want to delete. It is also possible to edit lines 5 and 7 to add some arguments such as ignoring some specifics user profiles as mentioned in the previously provided link.

  • Name: Douglas Sanchez
  • Company: Kaseya
  • Website:
  • Contact Developer
  • Summary
  • Cleanup User Profiles
  • Version:
  • Initially Released September 7th, 2018
  • Reviews
    Gravatar for Curtis Duck
    by Curtis Duck on February 19th, 2020

    Works after some modification and very inconsistent to say the least.

    Gravatar for Curtis Duck
    Curtis Duck about 1 year ago

    The procedure works only after adding .\ before the executable i.e. "& '#vAgentConfiguration.agentTempDir#\Delprof2 1.6.0\.\DelProf2.exe' /d:#days# /u /i" 

    I added (/ed:(excluded account here)) to permit exclusion of valuable accounts for local admins or others.

    I added  (| out-file #vAgentConfiguration.agentTempDir#\delprof.log) to the end of the command in order to log the output to see the results of the process. I also found that the reliability of Delprof2 to accurately determine use dates of profiles ifs inconsistent too say the least since the NTUSER.DAT file is used to determine the last login and this is modified by other system processes regularly. If you were to use the /ntuserini command this would possibly delete an active profile since this file is not updated by the logon process regularly. Any recommendations on how to make this more consistent?