1
我从工作中运行的性能计数器下面的脚本:返回性能计数器结果
$counter = {
param($TestLength)
$perfsample = Get-Counter -Counter `
"\PhysicalDisk(_Total)\% Disk Time",`
"\Processor(_Total)\% Processor Time",`
"\Process(_Total)\Working Set",`
"\Network Interface(*)\Bytes Total/Sec"`
-SampleInterval 1 -MaxSamples $TestLength -ErrorAction SilentlyContinue
$perfsample
}
Start-Job -Name GettingCounters -ScriptBlock $counter -ArgumentList $TestLength | Wait-Job
Export-Counter -Path $DestinationFile -FileFormat csv -InputObject (Receive-Job GettingCounters)
当运行上面的代码,我出现以下错误:
Export-Counter : Cannot bind parameter 'InputObject'. Cannot convert the "Micro
soft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet" value of type
"Deserialized.Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample
Set" to type "Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample
Set".
据我所知,这是由于输出序列化,所以有可能返回一个反序列化的输出?