计数器收集
#由于在windows2008下没有get-counter命令,所以现在其他计算机下收出所有counter到文件,然后再将该文件拿到08下利用后面的脚本去跑
#$countersr = get-counter -ListSet * -ComputerName win08
#foreach ($counterr in $countersr)
# {
# $counterr.paths |out-file c:\perc\counter_raw.txt -Append
# }
###########以下部分在win08上面运行########################
$results=@()
$counters = gc C:\perc\counter_raw.txt
foreach ($counter in $counters)
{
$result=""|select CounterSet,CounterName,CounterDescription
$cobj=New-Object system.Diagnostics.PerformanceCounter
if($counter.contains("*"))
{$cobj.categoryname=$result.counterset=($counter.split("\")[3]).split("(")[0]}
else{$cobj.categoryname=$result.counterset=$counter.split("\")[3]}
$cobj.countername=$result.countername=$counter.split("\")[4]
$result.CounterDescription=$cobj.CounterHelp
$results += $result
}
$results | export-csv -encoding utf8 -path c:\perc\result.csv -notypeinformation