Skip to content

Instantly share code, notes, and snippets.

@ScriptingPro
Last active February 3, 2020 21:23
Show Gist options
  • Save ScriptingPro/6861917dd25306940fae54743fa48d22 to your computer and use it in GitHub Desktop.
Save ScriptingPro/6861917dd25306940fae54743fa48d22 to your computer and use it in GitHub Desktop.
Remove Any Explicitly Defined Permissions for EVERYONE Security Principal
# this removes only non-inherited "EVERYONE" user recursively from folders
# execute this from the starting directory
gci -Recurse -Directory | %{
$Descriptor = Get-Acl $_.FullName
$Access2Remove = $Descriptor.Access | ?{$_.IdentityReference -eq 'Everyone' -and $_.IsInherited -eq $false}
if($Access2Remove){
$Descriptor.RemoveAccessRule($Access2Remove)
Set-Acl -Path $_.FullName -AclObject $Descriptor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment