Last active
August 29, 2015 14:16
-
-
Save mortenya/5b352720c95eee953101 to your computer and use it in GitHub Desktop.
Had a number of users in my environment that had AdminCount=1 and Security Inheritance disabled, AdminCount was easy, enabling inheritance required a bit more work. This is so I don't forget how I did it. Seems to take a few minutes to replicate up where ADUC will see the changes.
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
## list of users, I wanted to control exactly what got modified. | |
## this command will get all the users we want to work with: | |
### Get-ADUser -Filter * -Properties nTSecurityDescriptor | ` | |
### where { $_.nTSecurityDescriptor.AreAccessRulesProtected -eq $true } | ` | |
### select Name,SamAccountName,DistinguishedName,nTSecurityDescriptor | |
$users = Import-Csv C:\scripts\users.csv | |
## allows inheritance | |
[bool]$isProtected = $false | |
## preserves inherited rules | |
[bool]$PreserveInheritance = $true | |
foreach ($u in $users) | |
{ | |
$user = [ADSI]"LDAP://$($u.distinguishedName)" | |
$acl = $user.ObjectSecurity | |
if ($acl.AreAccessRulesProtected) | |
{ | |
$acl.SetAccessRuleProtection($isProtected,$PreserveInheritance) | |
$user.CommitChanges() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment