如果我有用户DSN
/LDPA://server.domain/cn=john smith, ou=users, ou=acme, ou=com
我如何获得用户?我认为它与
get-aduser -LDAPFilter "cn=john smith, ou=users, ou=acme, ou=com"
但它不起作用,文档实际上并未以这种方式显示它。任何人都知道如何在提供此信息时获取用户?
答案 0 :(得分:0)
非常接近,但LDAPFilter的域部分不是OU,它将是DC,有关详细信息,请参阅以下页面...
http://www.computerperformance.co.uk/powershell/powershell-get-aduser-filter.htm
答案 1 :(得分:-1)
我很接近,但上面的链接上没有例子。这就是我最终实现这一目标的方式。
# displayName
$DisplayName = $parameter1.SubString($loc1+1, $loc2-($loc1+1))
# -searchBase
$OULocation = $parameter1.SubString($loc2+1,($parameter1.length-1)-$loc2)
# get the user
$User = Get-ADUser -Filter {displayName -eq $DisplayName} -SearchBase $OULocation