Ref: https://blogs.msmvps.com/bradley/2010/02/28/getting-access-to-the-my-documents-redirected-folders/
This post is a copy of the article referenced above. Just read that if the link is still good. Otherwise I include it here because it is so useful, and things disappear on the web.
Download pstools (part of the sysinternals package).
I suggest you create c:\sysinternals, unzip it there, and add that to your path.
Copy the below to a script named ChangePermissions.ps1.
Change the two highlighted lines to suit your environment.
#ChangePermissions.ps1 # CACLS rights are usually # F = FullControl # C = Change # R = Readonly # W = Write $StartingDir= "E:\Users\shares" $Principal="INSERT_DOMAIN_NAME\ADMIN_USERNAME" $Permission="F" $Verify=Read-Host `n "You are about to change permissions on all" ` "files starting at"$StartingDir.ToUpper() `n "for security"` "principal"$Principal.ToUpper() ` "with new right of"$Permission.ToUpper()"."`n ` "Do you want to continue? [Y,N]" if ($Verify -eq "Y") { foreach ($file in $(Get-ChildItem $StartingDir -recurse)) { #display filename and old permissions write-Host -foregroundcolor Yellow $file.FullName #uncomment if you want to see old permissions #CACLS $file.FullName #ADD new permission with CACLS CACLS $file.FullName /E /P "${Principal}:${Permission}" >$NULL #display new permissions Write-Host -foregroundcolor Green "New Permissions" CACLS $file.FullName } }
Run the script from an elevated cmd prompt with this command:
psexec -s -i powershell -noexit "& 'C:\Path\To\ChangePermissions.ps1'"
It will recursively grant you access to everything in that path.