Created
June 30, 2014 09:32
-
-
Save Krelix/dfaf0710c3abe76a2c4c to your computer and use it in GitHub Desktop.
PowerShell - Change permissions and owner of all the files and directories in the current folder.
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
# Don't forget to ser $usernameFull to the name off account in this format : DOMAIN\username | |
$rule = new-object System.Security.AccessControl.FileSystemAccessRule($usernameFull, 'FullControl', 'Allow'); | |
$owner = new-object System.Security.Principal.NTAccount($usernameFull) | |
foreach($file in $(Get-ChildItem ./ -recurse)){ | |
$acl=get-acl $file.FullName | |
$acl.SetAccessRule($rule) | |
$acl.SetOwner($owner) | |
set-acl $file.FullName $acl | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment