2013-05-08 113 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