当我想使用此搜索AD时,我可以指定域控制器:
'$filter'
如何使用$principalContext = New-Object 'System.DirectoryServices.AccountManagement.PrincipalContext'([System.DirectoryServices.AccountManagement.ContextType]::Domain, $DomainControllerIpAddress, $Container)
或DirectoryEntry
?
答案 0 :(得分:3)
Multiple constructor overloads DirectorySearcher
以DirectoryEntry
作为参数,您可以在创建一个特定服务器时定位:
# [adsi] is a type accelerator for the DirectoryEntry class
$Entry = [adsi]"LDAP://dc01.domain.tld/OU=MyContainer,DC=domain,DC=tld"
# [adsisearcher] is a type accelerator for the DirectorySearcher class
$Searcher = [adsisearcher]$Entry