PowerShell Tip – How to set permissions that applies to folder, subfolder and files without iCacls?

It is very simple…

$path = 'C:\Temp'

New-Item -Path $path -ItemType directory
$acl = Get-Acl -Path $path
$permission = 'Everyone', 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permission
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path $path

Leave a Reply

Your email address will not be published. Required fields are marked *