none
Restore redirected folder permissions after restore

    Question

  • 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
    } 

    Monday, February 23, 2015 7:38 PM

Answers

  • Hi,

    >>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.

    The owners of the redirected folders should be the users whose folders are being redirected. Here, the following article focuses on restoring security settings and may be worth taking a look.

    How do I restore security settings to a known working state?

    http://support.microsoft.com/kb/313222

    >>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. ?

    For scripting questions, in order to get better help, it's recommeded that we ask for suggestions in the following scripting forum.

    The Official Scripting Guys Forum

    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

    Best regards,
    Frank Shen


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Tuesday, February 24, 2015 12:40 PM
    Moderator