PowerShell: Change File Owner Perm (ACL)

By Xah Lee. Date: . Last updated: .

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