Powershell - Manage File ACLs


Copy a File ACL
$acl = get-acl "c:\temp1"
set-acl "c:\temp2"


Modify a File ACL
$acl = get-acl "c:\temp1"
$ar = New-Object system.security.accesscontrol.filesystemaccessrule("user","FullControl","Allow")
$acl.setaccessrule ($ar)
set-acl "c:\temp1"


Find an ACL With an Entry
Find an ACL With an EntryFind an ACL With an Entryget-childitem i:\path\sharename | get-acl | select path,access, accesstostring | where {$_.accesstostring -like "*domainName\IT_Shares_Read_LG*" } |fl


Find an ACL Missing an Entry
Find an ACL Missing an EntryFind an ACL Missing an Entryget-childitem i:\path\sharename | get-acl | select path,access, accesstostring | where {$_.accesstostring -notlike "*domainName\IT_Shares_Read_LG*" } |fl

Comments