Hello,
Hope someone can give me some pointers, before i start destroying permissions
I have a client whom after changing the target folder in DFS management, messed up their redirected folders permissions (Desktop, Documents, pictures etc.) many of these doesn't even have a owner. So we tried different things today, new GPO new folder structure
etc. in the end we agreed that it would be easier to restore permissions, will this be best done by using a script?
The problem is that many of these folders dosnt even have a owner!! so before giving permissions i have to take ownership and the give permissions to the specific folder, i am trying to build a script (see below)
so my question is, will this work? and should create the script so it only changes the folders named according to folder redirection like Documents, Pictures etc. ? since some folders in their directory still works, apparently they have been given access to the unc path and added private folders.
$Folders = "UNC path" $Folder = Get-ChildItem $Folders $DomainName = "Domain" Foreach ($User in $Folder) { #Takeownership TAKEOWN /F $Folders$User /R /D Y $Username = $User.Name $UsernameAndDomain = $DomainName + "\" + $Username $FullPath = "$Folders" + "$UsernameAndDomain" ICACLS ("$FullPath") /grant ("$UsernameAndDomain" + ':(OI)(CI)F') /T ICACLS ("$FullPath") /grant '"Domain Admins":(OI)(CI)F' /T #Restoreownership ICACLS ("$FullPath") /setowner "Domain Admins" /c /t }