My new employer has folder redirection setup for its hundreds of users, and the person who set it up didn't really know what he was doing. As a result, the best practices for permissions on redirected folders/home directories was not followed.
The solution to let people access their redirected folder locations was to instead apply Full Control
permissions (NTFS permissions, not "share" permissions, of course) to Everyone
at the root directory ("Home") and propagate that down to all subfolders and files below the root.
What could possibly go wrong, right? It's not like the CEO has confidential information in his My Documents
folder, or anyone's going to get infected with CryptoWall and encrypt everyone else's files. Right?
So, anyway, now that the CryptoWall infection has been removed and backups have been restored, a number of people would like us to replace the current permissions with something less horrible, and I would like to not have to click around the permissions dialogues in several hundred folders.
How can PowerShell solve this problem for me, and make life worth living again?
With thanks to JScott for referring me to the
System.Security.Principal
... class or method or whatever it is, some PowerShell to replace the ACLs on a bunch of subfolders with those that are appropriate for user home directories:The previous answer won't work IF the home folders/redirected folders were set up with "Grant the user exclusive rights". This is because when this option is selected which is not recommended, only SYSTEM and THE USER have rights to the folder. You then cannot change the perms (even as admin) without taking ownership of the folder.
This IS a method to work-around this WITHOUT taking ownership. It is a two-step process.
Create a powershell script that runs ICACLS to modify the perms on the folders & subfolders.
run PSexec to kickoff Powershell script.
taken and modified from: https://mypkb.wordpress.com/2008/12/29/how-to-restore-administrators-access-to-redirected-my-documents-folder/
1 Create/copy/steal powershell script (requires PS 3.0 or better)
From Command Line: