Clean Roaming profiles from Windows Servers

Are you limited on disk space and need to clean up roaming profiles? Don’t want to manually search through the profiles to figure out when the last time the profile has been downloaded and used?

Well you are in luck as I have crafted this powershell script that will search for all roaming profiles and delete those that haven’t been downloaded in the last 60 days! You could of course modify how old of profile downloads you want to keep but 60 days I felt was a good result.

Get-CimInstance -ClassName win32_userprofile -Verbose | Where {($_.LastDownloadTime -ne $null) -and ($_.LastDownloadTime -lt $(Get-Date).Date.AddDays(-60))} | Remove-CimInstance -Verbose

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top