Skip to content

Instantly share code, notes, and snippets.

@jszabo98
Last active November 27, 2023 23:00
Show Gist options
  • Select an option

  • Save jszabo98/76c44fd04ee7d9ad831ccf18cd2c1097 to your computer and use it in GitHub Desktop.

Select an option

Save jszabo98/76c44fd04ee7d9ad831ccf18cd2c1097 to your computer and use it in GitHub Desktop.

Revisions

  1. jszabo98 revised this gist Mar 12, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions acls.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    .gist pre{font-family:Menlo,Monaco,'Bitstream Vera Sans Mono','Courier New',monospace !important}

    $acl = Get-Acl -Path C:\SpecialFolder\SpecialFile.txt
    $user = 'BillB'
    $rights = [System.Security.AccessControl.FileSystemRights]'ReadAndExecute, Write, Modify, Read' # enum flags
  2. jszabo98 revised this gist Mar 12, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions acls.ps1
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    .gist pre{font-family:Menlo,Monaco,'Bitstream Vera Sans Mono','Courier New',monospace !important}

    $acl = Get-Acl -Path C:\SpecialFolder\SpecialFile.txt
    $user = 'BillB'
    $rights = [System.Security.AccessControl.FileSystemRights]'ReadAndExecute, Write, Modify, Read' # enum flags
  3. jszabo98 created this gist Mar 12, 2018.
    19 changes: 19 additions & 0 deletions acls.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    $acl = Get-Acl -Path C:\SpecialFolder\SpecialFile.txt
    $user = 'BillB'
    $rights = [System.Security.AccessControl.FileSystemRights]'ReadAndExecute, Write, Modify, Read' # enum flags
    $rights

    Modify

    $RuleBillB = [System.Security.AccessControl.FileSystemAccessRule]::new($user, $rights, 'Allow')
    $RuleBillB

    FileSystemRights : Modify, Synchronize
    AccessControlType : Allow
    IdentityReference : BillB
    IsInherited : False
    InheritanceFlags : None
    PropagationFlags : None

    $acl.AddAccesssRule($RuleBillB)
    Set-Acl -Path C:\SpecialFolder\SpecialFile.txt -AclObject $acl