This code can be used in a StartUp GPO script or as a manual script to clear out stuck profiles on a server. This probably won’t delete the entire profile of users that are in use, but I haven’t tested that yet. This will just leave the default required profiles behind.
If you need any others left, just add them to the exclude list seperated by comma’s
$dirs = Get-ChildItem c:\Users -exclude Public,Default,Administrator,”All Users”,”Default User” $dirs |% {rd $_ -recurse -force}
Hope this helps
No comments yet... Be the first to leave a reply!