Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've recently discovered the "adminSDHolder" feature of Active Directory. I need a quick way to identify all users who will be affected by it, namely a script to dump the user accounts.

share|improve this question

3 Answers

up vote 13 down vote accepted

You can use this powershell script to return the users that have an adminCount greater than 0, which means that they are affected by the adminSDHolder feature. You'll need the AD Module for PowerShell installed, which comes with RSAT.

import-module activedirectory

get-aduser -Properties adminCount -Filter * -ResultSetSize $null| foreach-object{
   if ($_.adminCount -gt 0){
   echo $_
   }    
}

Edit:

As jbsmith points out, this should also work too, and is a bit cleaner:

import-module activedirectory

get-aduser -Filter {admincount -gt 0} -Properties adminCount -ResultSetSize $null| foreach-object{      
   echo $_          
}
share|improve this answer
4  
Here's a cleaner method of doing the same thing: get-aduser -filter {admincount -gt 0} -Properties admincount -ResultSetSize $null – jbsmith Aug 24 '11 at 20:18
also you could create a dsquery filter to do the same thing – tony roth Aug 25 '11 at 0:00
1  
@tony - You could, but the OP asked specifically for a PowerShell script. – MDMarra Aug 25 '11 at 2:53
([adsisearcher]"(AdminCount=1)").findall()
share|improve this answer
## Script name = Set-IheritablePermissionOnAllUsers.ps1
##
## sets the "Allow inheritable permissions from parent to propagate to this
##object"check box
# Contains DN of users
#
#$users = Get-Content C:\C:\Navdeep_DoNotDelete\variables\users.txt

Get-ADgroup -LDAPFilter “(admincount=1)” | select name

$users = Get-ADuser -LDAPFilter “(admincount=1)”

##Get-QADUser -SizeLimit 0 | Select-Object Name,@{n=’IncludeInheritablePermissions’;e={!$_.DirectoryEntry.PSBase.ObjectSecurity.AreAccessRulesProtected}} | Where {!$_.IncludeInheritablePermissions}

ForEach($user in $users)
{
# Binding the users to DS
$ou = [ADSI]("LDAP://" + $user)
$sec = $ou.psbase.objectSecurity
if ($sec.get_AreAccessRulesProtected())
{
$isProtected = $false ## allows inheritance
$preserveInheritance = $true ## preserver inhreited rules
$sec.SetAccessRuleProtection($isProtected, $preserveInheritance)
$ou.psbase.commitchanges()
Write-Host "$user is now inherting permissions";
}
else
{
Write-Host "$User Inheritable Permission already set"
}
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.