function htopish {
Param (
[Parameter(Position=1)] [Alias("l")]
[int]$TotalList=24,
[Parameter(Position=2)] [Alias("r")]
[int]$Invertal=1
)
Begin {}
Process {
While ($true) {
$CounterSamples = Get-Counter '\Process(*)\ID Process','\Process(*)\% Processor Time','\Process(*)\Working Set' | Select-Object -Expand CounterSamples
Clear-Host
$CounterSamples | Group-Object { Split-Path $_.Path } | Where-Object {$_.Group[1].InstanceName -notmatch "^Idle|_Total|System$"} | Sort-Object -Property {$_.Group[1].CookedValue} -Descending | Select-Object -First $TotalList | Format-Table @{Name="ProcessId";Expression={$_.Group[0].CookedValue}},@{Name="ProcessorUsage";Expression={[System.Math]::Round($_.Group[1].CookedValue/100/$env:NUMBER_OF_PROCESSORS,4)}},@{Name="ProcessName";Expression={$_.Group[1].InstanceName}},@{Name="WorkingSet";Expression={[System.Math]::Round($_.Group[2].CookedValue/1MB,4)}}
Sleep -Seconds $Invertal
}
}
End {}
}
function htopish {
Param (
[Parameter(Position=1)] [Alias("l")]
[int]$TotalList=24,
[Parameter(Position=2)] [Alias("r")]
[int]$Invertal=1
)
Begin {}
Process {
While ($true) {
$CounterSamples = Get-Counter '\Process(*)\ID Process','\Process(*)\% Processor Time','\Process(*)\Working Set' | Select-Object -Expand CounterSamples
Clear-Host
$CounterSamples | Group-Object { Split-Path $_.Path } | Where-Object {$_.Group[1].InstanceName -notmatch "^Idle|_Total|System$"} | Sort-Object -Property {$_.Group[1].CookedValue} -Descending | Select-Object -First $TotalList | Format-Table @{Name="ProcessId";Expression={$_.Group[0].CookedValue}},@{Name="ProcessorUsage";Expression={[System.Math]::Round($_.Group[1].CookedValue/100/$env:NUMBER_OF_PROCESSORS,4)}},@{Name="ProcessName";Expression={$_.Group[1].InstanceName}},@{Name="WorkingSet";Expression={[System.Math]::Round($_.Group[2].CookedValue/1MB,4)}}
Sleep -Seconds $Invertal
}
}
End {}
}
The function relies on the Get-Counter
samples and will output the ProcessId,ProcessName,ProcessorUsage
and WorkingSet
. This counter sample could further be enhanced to include User
,CommandLine
in the output but I haven't worked out yet a performant way to do it.
Function
relies on theGet-Counter
samples and will output theProcessId
,ProcessName
,ProcessorUsage
, andWorkingSet
.- This counter sample could be further enhanced to include
User
andCommandLine
in the output, but I haven't yet worked out a performant way to do so.