0

The command Get-Process gives output like below:

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
     65       6     1152        840    59    77.50   6048 Appx
     78       8     2233        444    61    10.11   7878 Application

but I need a solution like below:

PM(K)=1152, ProcessName=Appx ; PM(K)=2233, ProcessName=Application

How do I parse output like above mentioned?

2
  • 1
    this is a result of get-process not get-service Commented Jul 24, 2013 at 9:10
  • @Kayasax yes, its get-process only. got updated the same in the above question Commented Apr 8, 2015 at 10:00

2 Answers 2

2

you can use -f to format your string :

PS>$resu=""
PS>gps | foreach {$resu+=("PM(K)= {0},appName={1};" -f ($_.pm/1KB),$_.name) }
PS>$resu
Sign up to request clarification or add additional context in comments.

1 Comment

you are right, its get-process only. thanks u so much, its working like charming :)
0

Try something like this:

$p = Get-Process | select @{n='PM(K)';e={$_.PM/1KB}}, ProcessName
($p | fl | Out-String) -replace "`n`n", ' ; ' -replace "`n", ', '

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.