none
Set-Acl not applying permissions on folder RRS feed

  • Question

  • Hello,

    Can anyone explain why this isn't working? I can't seem to get it working. It creates the folder, adds user, but it dosn't apply the actual permissions on the folder. I don't get any errors. Windows 7.

    New-Item -type directory -path C:\MyFolder
    $Control = [System.Security.AccessControl.AccessControlType]::Allow 
    $Rights = [System.Security.AccessControl.FileSystemRights]"FullControl"
    $User = New-Object System.Security.Principal.NTAccount("testu")
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule `
        ($User, $Rights, $Control)
    $Acl = Get-Acl "C:\MyFolder"
    $Acl.AddAccessRule($Ar)
    Set-Acl "C:\MyFolder" $Acl

    Thanks

    Sam.

    Thursday, July 17, 2014 9:20 AM

Answers

  • Doh!

    It does set permissions on the folder, if you go to advanced settings, only applies to that folder though. Were I wanted it to apply to subfolders and files too.

    Thanks

    Sam

    • Marked as answer by Samc56198489 Thursday, July 17, 2014 9:42 AM
    Thursday, July 17, 2014 9:42 AM