locked
Locate multiple folders and change permission RRS feed

  • Question

  • Hi guys..

    I have been browsing the net to find something usefull but no luck so far.

    I have a file structure which contains several folders named Project 1, Project 2... and so on.
    Each Project folder contains four subfolders named Sales, Finance, Diverse, Calculation.

    My task is to browse thru all Projects and change file permissions on each "Diverse" folder.
    I can see that I have to use the command "SubInAcl.exe" but I am not sure how to combine that with a "For... Do... Next" routine. I guess I have to make an Array with all "Diverse" folder locations?

    • Moved by Bill_Stewart Wednesday, May 30, 2018 8:55 PM Unanswerable drive-by question
    Monday, April 16, 2018 11:13 AM

All replies

  • Hi C_FlashHeart 

    I used this script before to set the Folder permission on sub folders for a certain user group to give full access it migth work for you.  I would run on a test folder first to make sure it does what you need.  Just need to change the path and domain usergroup to what every you want to give access to and change the full control if you need to give less permisssions. 

    $Folders = Get-ChildItem -Path "Path to Folder" -Directory -Recurse | 
    Where-Object {$_.Name -like 'Diverse'}
    foreach ($Folder in $Folders)
    {
    $acl = Get-Acl -Path $Folder.FullName
    $accessRule = New-Object  system.security.accesscontrol.filesystemaccessrule("Domian\UserGroup","FullControl","Allow")
    
    $acl.SetAccessRule($accessRule)
    Set-Acl -Path $Folder.FullName -AclObject $acl
    }


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Monday, April 16, 2018 12:22 PM