【问题标题】:Export-Counter -Fileformat csv append?Export-Counter -Fileformat csv 追加?
【发布时间】:2013-01-16 11:06:24
【问题描述】:

我想对一组计算机运行 get counter 并将值输出到 csv ,我看到 Export-Counter 没有附加参数?

有人可以帮助解决如何使用 Export-Counter 附加更多信息的 csv,我知道 export-csv 有一个 append 参数,但是如果我想将数据附加到 Export-Counter 生成的 csv 中怎么办?

【问题讨论】:

标签: powershell


【解决方案1】:

我认为您在这里有 2 个选择。如果您需要它来打印报告,并使用 export-csv 保存它。例如:

Get-Counter | select ...(if you want need to modify output)| Export-Csv -Append test2.txt -NoTypeInformation

如果您需要稍后导入它(需要真正的 performancecountersampleset-object),请尝试将以前的存储在一个数组中并添加新的计数器。例如:

$path = "C:\test.csv"

#1st time
Get-Counter | Export-Counter $path -FileFormat csv

#Next time you use
$a = Import-Counter $path
$array = @($a)
$b = Get-Counter
$array += $b
$array | Export-Counter $path -FileFormat csv -Force

【讨论】:

    猜你喜欢
    • 2018-08-15
    • 1970-01-01
    • 2011-09-19
    • 2017-07-15
    • 1970-01-01
    • 2019-12-01
    • 2013-02-05
    • 2021-04-02
    • 2016-11-17
    相关资源
    最近更新 更多