2014-12-18 50 views
0

希望你能幫上忙。當我發出以下命令:Get-ADuser:搜索過濾器無法識別

$ G = GET-ADGroupMember -Server sbintldirectory.com -Identity組別1 $ N =得到-ADGroupMember -Server ad.msdsprd.com -Identity組別1 $ g.samaccountname |其中{$ n.samaccountname -notcontains $ psitem} | out-file c:\ temp \ new.txt $ users = gc C:\ Temp \ new.txt $ a = $ users | foreach {Get-ADuser -LDAPFilter「(samaccountname = $ )」-Server dc:3268} $ a |選擇samaccountname,distinguishedName | out-file c:\ temp \ list.txt $ group =「CN = group1,OU = Testing,DC = domain,DC = com」 get-content「c:\ temp \ list.txt」|的ForEach { Get-ADuser -LDAPFilter "(samaccountname eq $_)" -Server dc:3268 | ForEach {附加ADGroupMember -Identity $組 - 成員$ .distinguishedName}}

結果: GET-ADUser便有:搜索過濾器無法識別 在行:10字符:1 + GET-ADUser便有-LDAPFilter「(samaccountname eq $ _)」-Server dc:3268 |佛... + ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~類別信息:(未知):(:搜索過濾器無法識別,Microsoft.ActiveDirectory.Management.Commands.GetADUser

非常感謝。

回答

2

您正在使用-LDAPFilter錯誤地在這條線:

Get-ADuser -LDAPFilter "(samaccountname=$_)" -Server dc:3268 

-LDAPFilter是在LDAP語法寫一個過濾器。

你只是想獲得一個特定的用戶,其中$_已經代表用戶名:

Get-ADuser -Identity $_ -Server dc:3268 

參考the documentation on Get-ADUser有關屬性的詳細信息。

+0

感謝您的回覆。嘗試Get-ADuser -Identity -Server dc:3268並且得到了Get-ADuser:在DC:Domain,DC下找不到具有標識的對象:'<森林中不同域的 user4376180 2014-12-19 13:12:14