Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
workflow Invoke-PerfCounter {
param($counters)
foreach -parallel ($counter in $counters) {
(Get-Counter $counter).CounterSamples |
Select -Property Path, CookedValue } }
$counters =
'\Processor(*)\% Processor Time',
'\Processor(*)\% User Time',
'\Process(*)\Handle Count',
'\Process(*)\IO Read Operations/sec',
'\Process(*)\IO Write Operations/sec',
'\Process(*)\IO Data Operations/sec'
$start = Get-Date
Invoke-PerfCounter $counters | .\clip.exe
$end = Get-Date
$start
$end
$computer = $ENV:Computername
$instance = "_total"
# Disk counters...
@("\\$Computer\PhysicalDisk(*)\Current Disk Queue Length",
"\\$Computer\PhysicalDisk(*)\% Disk Time",
"\\$Computer\PhysicalDisk(*)\Avg. Disk Queue Length",
"\\$Computer\PhysicalDisk(*)\Avg. Disk Read Queue Length",
"\\$Computer\PhysicalDisk(*)\Avg. Disk Write Queue Length",
"\\$Computer\PhysicalDisk(*)\Avg. Disk sec/Transfer"
"\\$Computer\PhysicalDisk(*)\Avg. Disk sec/Read",
"\\$Computer\PhysicalDisk(*)\Avg. Disk sec/Write") |% {
(Get-Counter $_.replace("*",$instance)).CounterSamples } |
Select-Object Path,CookedValue |
Format-Table -AutoSize
# CPU counters
$computer = $ENV:Computername
$instance = "_total"
@("\\$Computer\Processor(*)\% Processor Time",
"\\$Computer\Processor(*)\% User Time",
"\\$Computer\Processor(*)\% Privileged Time",
"\\$Computer\Processor(*)\Interrupts/sec",
"\\$Computer\Processor(*)\% DPC Time",
"\\$Computer\Processor(*)\DPCs Queued/sec"
"\\$Computer\Processor(*)\% Idle Time",
"\\$Computer\Processor(*)\% Interrupt Time") |% {
(Get-Counter $_.replace("*",$instance)).CounterSamples } |
Select-Object Path,CookedValue |
Format-Table -AutoSize
# Memory counters
$computer = $ENV:Computername
$instance = "_total"
@("\\$Computer\Memory\Page Faults/sec",
"\\$Computer\Memory\Available Bytes",
"\\$Computer\Memory\Committed Bytes",
"\\$Computer\Memory\Commit Limit",
"\\$Computer\Memory\Pages/sec",
"\\$Computer\Memory\Free System Page Table Entries"
"\\$Computer\Memory\Pool Paged Resident Bytes",
"\\$Computer\Memory\Available MBytes") |% {
(Get-Counter $_.replace("*",$instance)).CounterSamples } |
Select-Object Path,CookedValue |
Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment