【发布时间】:2014-05-17 02:46:38
【问题描述】:
我正在尝试通过 Powershell 脚本从导出和更新的 CSV 文件中导入和替换 AD 中的电话号码。
我使用的脚本是:
Import-Csv C:\test2.csv | ForEach-Object {
Set-ADUser -Identity $_.samAccountName -Replace @{
telephoneNumber=$_.OfficePhone;HomePhone=$_.HomePhone;MobilePhone=$_.MobilePhone}
}
CSV 的格式为:
samaccountname,OfficePhone,HomePhone,MobilePhone
Username,Phone no, phone no, phone no
尝试导入时出现错误:
C:\Users\account\Desktop\ps2.ps1:2 char:13
+ Set-ADUser <<<< -Identity $_.samAccountName -Replace @{telephoneNumber=$_.OfficePhone;HomePhone=$_.HomePhone;Mobil
ePhone=$_.MobilePhone}
+ CategoryInfo : InvalidOperation: (1305:ADUser) [Set-ADUser], ADInvalidOperationException
+ FullyQualifiedErrorId : replace,Microsoft.ActiveDirectory.Management.Commands.SetADUser
有人知道吗?
【问题讨论】:
标签: powershell csv active-directory