2014-10-18 70 views
0

我試着使用如何填充在Active Directory中的管理領域,使用PowerShell

Import-Csv C:\Testimport.csv | ForEach-Object {Set-ADUser -Identity $_.samAccountName -Replace @{Manager=$_.manager}} 

以填充AD經理字段,但我得到以下錯誤:

Set-ADUser : Cannot bind parameter 'Replace' to the target. Exception setting " Replace": "Object reference not set to an instance of an object." At line:1 char:95 + Import-Csv C:\Testimport.csv | ForEach-Object {Set-ADUser -Identity $.samAcc ountName -Replace <<<< @{manager=$.manager}} + CategoryInfo : WriteError: (:) [Set-ADUser], ParameterBindingEx ception + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.ActiveDirectory
.Management.Commands.SetADUser

+0

您是否嘗試過解決此問題的任何內容? – 2014-10-18 13:34:15

回答

1

取決於什麼經理用你的csv代表,你可以自己使用Set-Aduser參數-Manager

Import-Csv C:\Testimport.csv | ForEach-Object {Set-ADUser -Identity $_.samAccountName -Manager $_.manager} 

如果不是,請在您的問題中顯示一些樣本日期。這將在Manager中起作用,至少是一個帳戶名稱。此外,您運行的代碼有錯誤:manager=$.manager應該是manager=$_.manager