Answers:
您可以使用此powershell脚本返回adminCount大于0的用户,这意味着他们受到adminSDHolder功能的影响。您将需要安装RSAT随附的用于PowerShell的AD模块。
import-module activedirectory
get-aduser -Filter {admincount -gt 0} -Properties adminCount -ResultSetSize $null
这是MDMarra出色回答的一个变体。
Import-Module ActiveDirectory
Get-ADUser -LDAPFilter "(admincount>0)" -Properties adminCount
这种用途-LDAPFilter代替-Filter。有些人喜欢使用LDAP过滤器语法,因为它可以在许多不同类型的应用程序中移植。
请注意,由于筛选器在服务器端执行,因此筛选器和LDAPFilter具有相似的性能特征。查询大型目录时,请始终尝试像这样直接进行过滤,而不要使用Where-Object
它会导致在过滤之前下载所有对象。在TechNet文章Filter vs. Where-Object上对此进行了详细描述。
-LDAPFilter
因此感谢您提及它并阐明它的好处。
## 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"
}
}