PowerShell: Change File Owner Perm (ACL)
What is Access Control Lists (ACL)
Access Control Lists (ACL) is a file permission system on Microsoft Windows.
Change a single file ACL
To set a file's permission on Windows, first find a file whose ACL is the one you want, get its ACL using get-acl
, then copy it to the files you want to set to, using set-acl
.
# change a single file ACL $perm = Get-Acl "~/t1.txt" $target = "~/t2.txt" Set-Acl $target -AclObject $perm
Change all file ACL in a dir
# change all file ACL in a dir $perm = Get-Acl "~/Documents/x.txt" dir "~/web/" -Recurse -file | Set-Acl -AclObject $perm
Change all dir's ACL in a dir
# change all dir's ACL in a dir $perm = Get-Acl "~/Documents/x.txt" dir "~/web/" -Recurse -directory | Set-Acl -AclObject $perm
PowerShell. File Properties, Attributes, Permission
- PowerShell: File Properties
- PowerShell: File Attributes
- PowerShell: List All Possible File Attribute Values
- PowerShell: Show a File's Attributes
- PowerShell: Show Hidden Files
- PowerShell: List Files with Specific Attribute
- PowerShell: Set a File's Attributes
- PowerShell: Set File Read Only Attribute
- PowerShell: File Attributes Object Type
- PowerShell: Change File Owner Perm (ACL)