adminCount> 0のADユーザーを見つけるPowerShellスクリプト


17

私は最近、Active Directoryの「adminSDHolder」機能を発見しました。影響を受けるすべてのユーザーをすばやく特定する方法、つまりユーザーアカウントをダンプするスクリプトが必要です。

回答:


18

このpowershellスクリプトを使用して、0より大きいadminCountを持つユーザーを返すことができます。これは、adminSDHolder機能の影響を受けることを意味します。RSATに付属しているPowerShell用ADモジュールをインストールする必要があります。

import-module activedirectory

get-aduser -Filter {admincount -gt 0} -Properties adminCount -ResultSetSize $null      

4
同じことを行うよりクリーンな方法を次に示します。get-aduser -filter {admincount -gt 0} -Properties admincount -ResultSetSize $ null
jbsmith

また、同じことを行うためにdsqueryフィルターを作成することもできます
トニーロス

2
@tony-可能ですが、OPはPowerShellスクリプトを特に要求しました。
MDマーラ


2

これは、MDMarraによる優れた答えの変形です。

Import-Module ActiveDirectory
Get-ADUser -LDAPFilter "(admincount>0)" -Properties adminCount

これは、-Filterの代わりに-LDAPFilterを使用します。LDAPフィルター構文は多くの異なる種類のアプリケーションに移植できるため、LDAPフィルター構文の使用を好む人もいます。

フィルターはサーバー側で実行されるため、FilterとLDAPFilterのパフォーマンス特性は似ていることに注意してください。大きなディレクトリをクエリするときは、フィルタリングのWhere-Object前にすべてのオブジェクトがダウンロードされる原因になるのではなく、常にこのように直接フィルタリングを実行してください。これについては、TechNetの記事FilterとWhere-Objectで詳しく説明されています。


私は頻繁にユーザーです-LDAPFilterので、言及し、その利点を明確にしていただきありがとうございます。
jscott

-2
## 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"
}
}

1
これは、OPが探していたものではない許可変更します。また、これらのオブジェクトのアクセス許可を変更しても、それほど大きな効果はありません。次回AdminSDHolderプロセスを実行すると、アクセス許可がリセットされます。
MDマーラ

3
ここにドラゴンがいます。
トム・オコナー
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.