use*_*879 3 scripting windows powershell active-directory csv
我正在尝试编写一个powershell脚本来更改comment使用csv和的电脑列表中名为“ ”的 属性import-Csv。
这是我的脚本
$computers=Import-Csv -Path "C:\sds.csv"
foreach ($item in $computers){
Set-ADComputer -identity $computers.DistinguishedName -add @{comment="bara"}
}
Run Code Online (Sandbox Code Playgroud)
并听到我的csv文件位于"C:\sds.csv"
但它跳到这个..
尝试谷歌搜索并在这里和那里更改,但不起作用!我对power-shell脚本了解甚少,但希望学习。有人可以指导我请什么我搞砸了?
小智 5
在您的 中for,您必须处理当前项目而不是computers集合。因此,您必须computers通过item以下方式更改命令:
Set-ADComputer -identity $item.DistinguishedName -add @{comment="bara"}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1747 次 |
| 最近记录: |