OpsaC - Operating as PowerShell code
published: March 18, 2015 author: Tinu tags: Accounts - Active Directory categories: Active Directory
Alle Domain Admins einer Domain auflisten
$domainDnsName = read-host "Enter the DNS Domain Name to connect to"
$accountName = 'Domain Admins'
$searcher = New-Object DirectoryServices.DirectorySearcher
$searcher.Filter = "(sAMAccountName=$accountName)"
$searcher.SearchRoot = "LDAP://$domainDnsName"
$searcher.PageSize = 100
$ret = $searcher.FindOne()
#LDAP-Path to the 'Domain Admins'
$members = $ret.GetDirectoryEntry().Member
$members | %{
#Bind to the User-Object and return the given properties
[adsi] "LDAP://$($_)" | Select sAMAccountName, DisplayName, Description
}