Powershell Needful Things put that in your pipeline

18May/092

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:
Comments (2) Trackbacks (0)
  1. I’ve been using this script and it works well. There is one particular folder within the UNC which I would like to exclude from being renamed. Do you know if there is a way I can add an exclusion into the script?
    Thanks


Leave a comment

No trackbacks yet.