【发布时间】:2020-10-18 20:34:21
【问题描述】:
我有一个 CSV 文件,其中包含 A 列上的用户列表 (samaccountname)。 在其他列上,我想设置其他属性值 对于这些用户中的每一个:
“办公室”在 B 列,“部门”在 C 列,公司在 D 列:
请帮助组装正确的 Powershell Synatx。
到目前为止,我已经尝试了以下方法:
Import-Module Activedirectory
$Attribcsv=Import-csv "D:\powershell\ADuserinformation\SetUserAttributes.csv"
ForEach ($User in $Attribcsv)
{
Set-ADUser $User.samaccountname -department $._Department
}
使用具有两列的不同 csv:sAMAcountName,Department
但我得到了一个错误:
【问题讨论】:
-
请展示您的尝试
-
已编辑,使用我尝试过的代码。
标签: powershell