2013-05-08 168 views
0

拥有csv的姓氏,名字,并且似乎无法将用户解析为其SamAccountName。无论我如何尝试,我都会收到以下错误。以下是错误。从显示名称解析SamAccount名称

我试图不使用任务命令。

Get-ADUser : Cannot find an object with identity: 'doe, john' under: 'DC=corp,DC=company,DC=ORG'. 
At line:1 char:11 
+ get-aduser <<<< "doe, john" 
    + CategoryInfo   : ObjectNotFound: (doe, john:ADUser) [Get-ADUse 
    r], ADIdentityNotFoundException 
    + FullyQualifiedErrorId : Cannot find an object with identity: 'doe, john' under: 'DC=corp,DC=company,DC=ORG'.,Microsoft.ActiveDirectory.Management. 
    Commands.GetADUser 

回答

0

首先解决:您可以使用LDAPFilter财产

Get-ADUser -LDAPFilter '(&(sn=Doe)(GivenName=jean Paul))' 

解决方法二:您可以使用筛选器属性

Get-ADUser -Filter "sn -eq 'Doe' -and givenName -eq 'Jean Paul'" 
+0

不错!谢谢JP。把这些命令放到一个变量中,然后用.samaccountname来得到结果。 – bruteForcePS 2013-05-08 06:47:39