Have any questions

Delete Unwanted Windows Users’ Profile from the System

Have multiple users been moved from or left your organization but their user profiles are still active? With this script, you can delete User Profiles that have remained inactive for X number of days


$d = (get-date).AddDays(-30) 

$prof = @(ls c:\users -Exclude “Administrator”) 


foreach($i in $prof){ 

if($i.lastwritetime –lt $d){ 

$tobedeleted += $i } 



Download Full Script

Purpose:Administrator can delete windows user profiles that are older than X number of Days. Days can be modified in the script as per need, deleted logs would be saved under the path defined in the script
Modification:Administrator can modify the script as per their requirements
Type:PowerShell Script (ps1)  
Reference link: