Group Policy: Automatically Delete User Profiles Older Than Certain Number of Days Win 10 not working.

P. Amila Mahesh Muthukumarana 26 Reputation points
2021-06-18T07:05:45.63+00:00

Hi

I enabled Computer Configuration\Administrative Templates\System\User Profiles\Delete User Profiles Older Than xxx GPO and apply to Windows 10 PCs.
Dayes set to 90.
Unfortunately, this didn't remove old data folders in C:\user.
I checked the registry HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System was added the REG_DWORD
I'm using Win 2019 domain and Win 10 client PC's.
Can someone help me to fix this?
The link which I use is https://social.technet.microsoft.com/wiki/contents/articles/28647.group-policy-how-to-automatically-delete-user-profiles-older-than-certain-number-of-days.aspx

Kr,
Amila.

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,466 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,642 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,159 questions
{count} vote

Accepted answer
  1. Hannah Xiong 6,231 Reputation points
    2021-06-18T09:03:43.997+00:00

    Hello @P. Amila Mahesh Muthukumarana ,

    Thanks for posting here.

    I did the testing in my lab, and below are the findings.

    The group policy was configured as shown below.

    106946-image.png

    106947-image.png

    This policy setting allows an administrator to automatically delete user profiles on system restart that have not been used within a specified number of days. Note: One day is interpreted as 24 hours after a specific user profile was accessed.

    If you enable this policy setting, the User Profile Service will automatically delete on the next system restart all user profiles on the computer that have not been used within the specified number of days.

    So I restarted the system and then checked the folders under C:\Users and User profiles were deleted.

    106978-image.png

    106948-image.png

    Hope it helps. For any question, please post here.

    Best regards,
    Hannah Xiong

    1 person found this answer helpful.

9 additional answers

Sort by: Most helpful
  1. Joseph Riling 6 Reputation points
    2023-01-05T13:41:33.867+00:00

    Hi Donna,

    We have been testing this across some of our sites and it seems to be working.


  2. Paul Eddy 0 Reputation points
    2023-02-02T18:15:42.4966667+00:00

    I was able to get this powershell to work when assigned to GPO as a startup script

    0 comments No comments

  3. Mikkel Halling Steen 0 Reputation points
    2023-02-13T14:32:50.8666667+00:00

    Open Notepad in win 10 and type

    @ECHO ON

    SET TmpBatch=%temp%~tmpLogonMessage.cmd

    IF EXIST "%TmpBatch%" DEL /Q /F "%TmpBatch%"

    SET msgboxTitle=

    SET msgboxLine1=User profiles older than 10 days are automatically deleted from this computer.

    SET tmpmsgbox=%temp%~tmpmsgbox.vbs

    ECHO @ECHO OFF >>"%TmpBatch%"

    ECHO IF EXIST "%tmpmsgbox%" DEL /F /Q "%tmpmsgbox%" >>"%TmpBatch%"

    ECHO ECHO msgbox "%msgboxLine1%",48,"%msgboxTitle%"^>"%tmpmsgbox%" >>"%TmpBatch%"

    ECHO WSCRIPT "%tmpmsgbox%" >>"%TmpBatch%"

    START /MIN CMD /C "%TmpBatch%"

    EXIT /B

    Save as bat.file on your desktop

    Copy the batch file to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp.

    0 comments No comments

  4. Rytram 0 Reputation points
    2023-11-08T05:46:26.55+00:00

    Hello.

    This was an issue that plagues me at my previous job. The company I worked for used micro PC's such as Lenovo's and Dell Optiplex computers. The main issue was the meager 128GB drives becoming full and bogging the computer down. This is inevitably an issue that will come up at any business that uses roaming profiles (which is most).

    This is not a water tight solution, but a pretty decent attempt at addressing the issue.

    My Method uses the last modified date of a users folder as a baseline for their inactivity. From there, I with some assistance, created a script that reads all users, their folder size, and last modified dates all in one nifty little popup window with check boxes and a delete option.

    Here is the script we came up with. I would be glad for feedback and modification suggestions. Such as replacing last modified date of user folder with the UsrClass.Dat date.

    user cleanup PS script.txt

    0 comments No comments