We have a very manual process here where when servers start filling up disk space, we go the user profiles in C:Users and delete folders that are over 24 hours old that begin with “Z” as our offshore resources don’t tend to follow the logoff process and leave old profiles in place.
I’m working on a PS script to remove and folders that begin with Z from the C:Users folder but I am finding it goes after anything with Z in it in other subfolders of other users.
Get-ChildItem -Path C:Users -Recurse | Where-Object {$_.Name -ilike “z*”} | Remove-Item -Force
Mulgrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.