Forum Discussion
John Andrews
Nov 17, 2021Copper Contributor
Windows 10 Delete User Profiles Older Than 60 Days
Hi. I am working on trying to automate cleaning up local user profiles on some machines that after awhile run into HDD space issues. I've been working on a script below for this, but I cannot get it ...
SteveMacNZ
Nov 18, 2021Iron Contributor
Hi John,
This is what i use in my transcription log file clean up to clean up log files older than 15 days- may be of use...
Get-ChildItem $PSScriptRoot -recurse "*$Script:ScriptName.log" -force | Where-Object {$_.lastwritetime -lt (get-date).adddays(-15)} | Remove-Item -force