Created
March 24, 2015 17:48
-
-
Save aaronpmiller/4cd690cfbca7e6d0bca7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$counters = (Get-Counter -ListSet Process).Counter | ? {$_ -like "*Bytes"} | % {$_.Replace('*','Powershell*')} | |
[string[]]$CounterNames = $counters | % {$_.split('\')[-1].ToLower()} | |
[string[]]$itemProperties = @() | |
$itemProperties += 'Timestamp' | |
$itemProperties += $CounterNames | ForEach-Object {$_.Replace('bytes','(MB)')} | |
$blankItem = '' | Select $itemProperties | |
Get-Counter -Counter $counters -SampleInterval 2 -Continuous| % { | |
$item = $blankItem | |
$item.Timestamp = $_.Timestamp | |
$groups = $_.countersamples | Group-Object {Split-Path $_.Path -Leaf} | |
foreach ($CounterName in $CounterNames) { | |
$item.$($CounterName.Replace('bytes','(MB)')) = (($groups | Where-Object {$_.Name -eq $CounterName}).Group | Measure-Object -Sum CookedValue).Sum/1MB | |
} | |
$item | |
} | Out-GridView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment