Update: Automatically clean up orphaned user directories

 As an update to the automatic cleanup script, this script will do essentially the same, but will also attempt to take ownership of the folder before renaming it. This was added because some of our users had full control on their folders, and removed all other permission from the folder.

There is a slight problem with get-acl and set-acl. The ownership will fail if you can’t read the ACL. If that fails, as a last resort, the script writes the failures out to a text file, which can be used as a batch file with a little utility called takeown.exe which will take ownership of the folders regardless. On a re-run of the script, the rename will succeed.

You can download the script from here: