-2

関連する ProductVersion とともに I/O 読み取りが多いプロセスのリストを取得しようとしています。コードは次のようになります。

$counter = "\Process*\IO Read Operations/sec"
get-counter | ? {$counter -gt 10} | gps | select name,productversion,reads

出力は次のようになります。

Name    ProductVersion    Reads
-----   --------------    -----
p1      16.1.723.2342     15.98324
p2      12.3.234.1231     11.34323
4

2 に答える 2

1

Format-Tableを使用できると思います

システムで結果を取得するために別のカウンターを使用しています。類推を引き出し、それに応じて使用できます:-

$Proc = Get-counter "\Process(*)\% processor time"

$Proc.CounterSamples | where {$_.instanceName -ne "idle"} | where {$_.instanceName -ne "_total"} | Format-Table -auto

出力:-

Path                                                                   InstanceName                          CookedValue
----                                                                   ------------                          -----------
\\angshuman\process(system)\% processor time                           system                           1.54907723252374
\\angshuman\process(smss)\% processor time                             smss                                            0
\\angshuman\process(csrss#1)\% processor time                          csrss                            1.54907723252374
于 2012-06-18T21:26:11.713 に答える
0

複数のソースからカスタム テーブルを作成するには、配列を作成し、各変数を新しいオブジェクトとしてパイプする必要があります。

$counter = "\Process*\IO Read Operations/sec"
$processes = gps | select id | ForEach {$_.id}
$ccounter = get-counter -listset process | get-counter -maxsamples 1 | select -expandproperty countersamples | where {$_.path -like $counter -and $_cookedvalue -eq $processes} | select cookedvalue | ForEach {$_.cookedvalue}
function Get-CounterValue ($mypid) { Code Here.... }
function GetProductVersion ($mypid) { ...code here... }
function GetProcessName ($mypid) { ...code here... }

$myresults = @()
$x = foreach ($procc in $processes) {
 $thisname = GetProcessName $procc
 $thisprod = GetProductVersion $procc
 $thisread = GetCounterValue $procc
 $robj = New-Object System.Object
 $robj | Add-Member -type NoteProperty -name Name -value $thisname
 $robj | Add-Member -type NoteProperty -name ProductVersion -value $thisprod
 $robj | Add-Member -type NoteProperty -name Reads -value $thisread
 $myresults += $robj
}
$myresults | ft -auto
于 2012-06-20T19:29:25.223 に答える