The good old Group Policy “Configuration\Policies\Administrative Templates\System\User Profiles\Delete User Profiles Older than a Specified Number of Days on System Restart ” isn’t part of Intune yet.
If you use shared devices in your environment, you can use below script to set the number of days after which a user profile is cleaned up on Windows 10 MDM / Intune managed.
It has to run under SYSTEM context or it won’t be allowed to write the right key.

Download: https://gitlab.com/Lieben/assortedFunctions/blob/master/set-CleanupUserProfilesAfterDays.ps1
Do you know if this has been resolved? We have about 5k student devices in our environment and we cannot find a resolution to this. Even these scripts that we deploy, they dont 100% always work. Just curious.
Hi there,
Very helpful script! Works great in the environment I’m in.
I’m wondering though, is there any way to add profiles to exclude from the delete? Like local profiles that are Administrators?
Thanks greatly!
Can this very useful script be adapted so that User Profiles that have not been updated in 30 days (i.e. guest user has not logged in for at least 30 days) triggers the delete?