Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Domain Admins

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
}

← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →