Created
February 1, 2019 14:46
-
-
Save mbrownnycnyc/41a315f2da2e5ef90224276223ea0ba0 to your computer and use it in GitHub Desktop.
get-acl/set-acl example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userfqdn = "matt-surface\scanner" | |
$targetfolder = "C:\Users\Matt\Desktop\hassio" | |
$acl = get-acl $targetfolder | |
$acl.setaccessruleprotection($false, $false) | |
# FileSystemRights enum: https://docs.microsoft.com/en-us/dotnet/api/system.security.accesscontrol.filesystemrights?view=netframework-4.7.2 | |
# InheritanceFlags enum: https://docs.microsoft.com/en-us/dotnet/api/system.security.accesscontrol.inheritanceflags?view=netframework-4.7.2 | |
$ruleReadOnly = New-Object System.Security.AccessControl.FileSystemAccessRule($userfqdn,"ReadAndExecute", "ContainerInherit, ObjectInherit", "None", "Allow") | |
$ruleModify = New-Object System.Security.AccessControl.FileSystemAccessRule($userfqdn,"Modify", "ContainerInherit, ObjectInherit", "None", "Allow") | |
$ruleFullAccess = New-Object System.Security.AccessControl.FileSystemAccessRule($userfqdn,"FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") | |
$acl.addaccessrule($ruleReadOnly) | |
set-acl $targetfolder $acl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment