无法更改Powershell 4中的属性

时间:2019-03-15 11:08:08

标签: powershell active-directory

你好,我尝试替换powershell中的以下属性

ForEach ($usr in $users)
{   
        Set-ADUser -Identity $usr.SamAccountName -Replace @{officePhone=$usr.ipPhone}| Where-Object {$_.DistinguishedName -like "*,$BaseOU"}
}

我收到了如下错误

Set-ADUser : Cannot bind parameter 'Replace' to the target. Exception setting "Replace": "Object reference not set to an 
instance of an object."
At C:\test\PhonesReplace.ps1:62 char:59
+         Set-ADUser -Identity $usr.SamAccountName -Replace @{officePhone=$usr.ipP ...
+                                                           ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Set-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.ActiveDirectory.Management.Commands.SetADUser

我从csv文件中获取价值,我看起来像这样

SamAccountName,Firstname,officePhone,Mobile,LastName,PayRoll aserigad,Marta,+ 48225694,+ 48225694,Aserigu,203207

我不确定为什么即使这个属性存在也不能接受ipphone。

enter image description here

0 个答案:

没有答案