我试图编写一个powershell
脚本来改变使用csv
和import-Csv
的电脑列表中的名为“ comment
”的属性。
这是我的脚本
$computers=Import-Csv -Path "C:\sds.csv" foreach ($item in $computers){ Set-ADComputer -identity $computers.DistinguishedName -add @{comment="bara"} }
听到是我的csv
文件位于"C:\sds.csv"
但它跳到这..
试图用googlesearch和改变,但不起作用! 我对power-shell脚本的理解很less,但是希望学习。 有人可以指导我什么即时搞乱?
在你for
,你必须在当前的项目,而不是从computers
集合。 所以你必须改变你的命令computers
的item
:
Set-ADComputer -identity $item.DistinguishedName -add @{comment="bara"}