Group Policy: How to Automatically Delete User Profiles Older Than Certain Number of Days
Introduction
Deleting User Profiles from a Windows system could be done through its system properties. This is an easy task when you only have a few computers to manage but you certainly do not want to do it manually when you manage hundreds or thousands of Windows systems. This Wiki shares how you can easily configure an automatic cleanup of User Profiles older than a certain number of days using Group Policy.
Steps to Enable automatic cleanup of User profiles
To enable an automatic Cleanup of User Profiles older than a certain number of days using Group Policy, you will need to set the setting Delete user profiles older than a specified number days on system restart under Computer Configuration\Administrative Templates\System\User Profiles to be Enabled and to specify the number of days after which a User Profile can be deleted if it is unused.
The cleanup is done when a system reboot is executed. You have then to be sure that the systems on which this setting is applied are frequently rebooted so that the cleanup is processed as expected.
Display message to describe the behaviour at logon
We have now shared how the cleanup could be enabled. However, your end users might become unhappy because of the automatic cleanup if they are not aware of it. A “smart” way to make your end users aware of the applied cleanup policy is to display a message describing the behavior at each user logon.
To make this true, you can use a Group Policy to update the following registry entries on your Windows systems:
- legalnoticecaption (REG_SZ) under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System: This entry can be used to specify the title of your message (Example” Welcome to [Company Name] Network”).
- Legalnoticetext (REG_SZ) under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System: This entry can be used to specify the text of your message (Example: Please note that your data will automatically be removed from this computer if you do not use it for 30 days. Thank you.)
Once this is applied, your users will be informed about the Cleanup policy before they get inside their profile.