locked
get-counter asynchronously RRS feed

  • Question

  • Hi

    Please see below script extract  to gather performance counters. As you can see I get 5 sec intervals on some of the counters so it takes roughly 40 seconds to run through this portion of the script synchronously.

    What would be the best way to run these commands asynchronously but stil have the variables available to use at the next stage of the script..

    #RUN PERFORMANCE COUNTER CHECKS

    $CPUused = Get-Counter "\\server\Processor(_total)\% Processor Time" -sampleinterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue, 2)}
    $MEMavail = Get-Counter "\\server\Memory\Available Mbytes" | Foreach { $_.CounterSamples[0].CookedValue }
    $MEMread = Get-Counter "\\server\Memory\Page Reads/sec" -SampleInterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue, 2)}
    $DISKread = Get-Counter "\\server\LogicalDisk(_total)\Avg. Disk sec/Read" -sampleinterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue, 4)}
    $DISKwrite = Get-Counter "\\server\LogicalDisk(_total)\Avg. Disk sec/Write" -sampleinterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue, 4)}
    $Traffic = Get-Counter "\\server\Network Interface(broadcom bcm5709c netxtreme ii gige [ndis vbd client])\Bytes Total/sec" -sampleinterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue /1MB, 2)}
    $emails = Get-Counter "\\server\MSExchangeIS Mailbox(_total)\Messages Delivered/sec" -SampleInterval 5| Foreach {[math]::round($_.CounterSamples[0].CookedValue, 2)}
    $RPCReq = Get-Counter "\\server\MSExchangeIS\RPC Requests" -sampleinterval 5 | Foreach { $_.CounterSamples[0].CookedValue }
    $RPClat = Get-Counter "\\server\MSExchangeIS\RPC Averaged Latency" | Foreach { $_.CounterSamples[0].CookedValue }
    $RPCOps = Get-Counter "\\server\MSExchangeIS\RPC Operations/sec" -sampleinterval 5 | Foreach {[math]::round($_.CounterSamples[0].CookedValue, 2)}
    $RPCOpsout = Get-Counter "\\server\MSExchange Store Interface(_total)\RPC Requests Outstanding" -sampleinterval 5 | Foreach { $_.CounterSamples[0].CookedValue }

     

    Tuesday, August 31, 2010 9:08 AM

Answers

All replies