Delete user profiles older than a specified number of days on system restart
Supprimer au redémarrage du système les profils utilisateur plus anciens qu’un nombre de jours spécifiés
Explanation
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.
If you disable or do not configure this policy setting, User Profile Service will not automatically delete any profiles on the next system restart.
Ce paramètre de stratégie permet à un administrateur de supprimer automatiquement au redémarrage du système des profils utilisateur qui n’ont pas été utilisés pendant un nombre de jours spécifié. Remarque : un jour est interprété comme étant 24 heures après l’accès à un profil utilisateur spécifique.
Si vous activez ce paramètre de stratégie, le service Profil utilisateur supprime automatiquement au redémarrage suivant du système tous les profils utilisateur qui n’ont pas été utilisés au cours du nombre de jours spécifié.
Si vous désactivez ce paramètre de stratégie ou ne le configurez pas, le service Profil utilisateur ne supprime automatiquement aucun profil au redémarrage suivant du système.
Registry
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System- Value name
- not defined in the ADMX
Enable / disable values: not defined in the ADMX (see the options below).
PowerShell
PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.
Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.
Enable
# Enable: UserProfiles/CleanupProfiles
$k = 'HKLM:\Software\Policies\Microsoft\Windows\System'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
# Delete user profiles older than (days)
Set-ItemProperty -Path $k -Name 'CleanupProfiles' -Value 30 -Type DWord # between 1 and 99999Disable
# Disable: UserProfiles/CleanupProfiles
# No value is written in the "Disabled" state (nothing defined in the ADMX)Revert to "Not configured"
# Revert to "Not configured": UserProfiles/CleanupProfiles
$k = 'HKLM:\Software\Policies\Microsoft\Windows\System'
Remove-ItemProperty -Path $k -Name 'CleanupProfiles' -ErrorAction SilentlyContinueOptions (1)
| Label | Control | Registry value | REG type | Constraints / details |
|---|---|---|---|---|
| Delete user profiles older than (days)Supprimer les profils utilisateur plus anciens que (jours)CleanupProfiles_Days | Numeric boxdecimal | CleanupProfiles | REG_DWORD | Required · Min: 1 · Max: 99999 · Default (UI): 30 |