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".
據我所知,這是由於輸出序列化,所以有可能返回一個反序列化的輸出?