Snippets

Doug Freed Revoke_Write.ps1

Created by Doug Freed
1
2
3
$myacl = Get-Acl -Path somefile
$myacl.Access | % { $colRights = [System.Security.AccessControl.FileSystemRights]"Write"; $InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::None; $PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None; $objType = [System.Security.AccessControl.AccessControlType]::Deny; $objUser = $_.IdentityReference; $objACE = New-Object System.Security.AccessControl.FileSystemAccessRule ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType); $myacl.AddAccessRule($objACE); }
Set-Acl -Path somefile -AclObject $myacl

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.