【发布时间】:2020-09-15 14:36:18
【问题描述】:
我正在尝试使用 power shell 来确定服务器是否安装了基于 KB 的特定补丁,如果没有,则将名称附加到 csv。我的输入文件有系统名称,所以如果找不到安装的补丁,我想导出该系统名称。
这是我到目前为止所拥有的。导出到 csv 部分似乎不起作用。
forEach-Object{
try{
$status = wmic /node:@sys.csv qfe list full /format:table | findstr /i $kb_number
if(!$status){
$output_file = New-Item C:\temp\$kb_number.csv -ItemType File
export-csv $output_file -append -Force
}
else{
write-output $status
}
}
catch{
$error_message = $_.Exception.Message
#write-output "the error message is" $error_message
write-output "Could not find any system with this patch installed."
}
}
【问题讨论】:
标签: powershell foreach