2012-06-18 1 views
-2

관련된 ProductVersion과 함께 I/O 읽기가 많은 프로세스 목록을 가져 오려고합니다.Powershell 각 프로세스 및 프로세스 정보가있는 목록에 대한 IO 작업 검색

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

을 출력은 다음과 같이 보일 것이다 : 코드는 다음과 같을 것입니다 당신이 나는 결과를 가져 오는에 대해 다른 카운터를 사용하고 Format-Table

를 사용할 수 있다고 생각

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

답변

1

을 내 시스템에. 당신은 비유를 끌어 따라 사용할 수 있습니다 : -

$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 
+0

출력을 표시하기 위해 Format-Table을 사용할 수 있다는 것을 알고 있습니다. 그러나 여기서 트릭은 프로세스 정보와 함께 카운터를 얻어야한다는 것입니다. 방금 카운터를 필요로한다면 당신의 대답은 정확할 것입니다; 그러나 나는 그렇지 않습니다. 그래도 고마워. –

+0

첫 번째 열이 표시되면 프로세스 정보가 –

+0

입니다. 찾고있는 프로세스 정보는 ProductVersion입니다. 질문을 자세히 읽으십시오. –

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 
관련 문제