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 ACL for a single file
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.
$xacl = Get-Acl "~/t1.txt" $target = "~/t2.txt" Set-Acl $target -AclObject $xacl
Change ACL for all files in a dir
$xacl = Get-Acl "~/Documents/x.txt" dir "~/web/" -Recurse -file | Set-Acl -AclObject $xacl
Change ACL for all dir in a dir
$xacl = Get-Acl "~/Documents/x.txt" dir "~/web/" -Recurse -directory | Set-Acl -AclObject $xacl
PowerShell. File Properties, Attributes, Permission
- PowerShell: File Properties
- PowerShell: File Attributes
- PowerShell: Meaning of mode column letters in dir output
- PowerShell: List All Possible File Attribute Values
- PowerShell: Show File 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)