Last active
February 3, 2020 21:23
-
-
Save ScriptingPro/6861917dd25306940fae54743fa48d22 to your computer and use it in GitHub Desktop.
Remove Any Explicitly Defined Permissions for EVERYONE Security Principal
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
# 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