Link to home
Start Free TrialLog in
Avatar of McThump
McThump

asked on

How to write formatted get-process output to a file

I need a Powershell script to save the output of get-process to a text file.  It should have the following columns:  ProcessName, WS and CPU.  I tried this command:

get-process | sort-object WS -descending | select ProcessName, WS, CPU | add-content c:\temp\procmem.txt

It produced the following output:

@{ProcessName=iexplore; WS=378351616; CPU=134.6756633}
@{ProcessName=iexplore; WS=216297472; CPU=47.2527029}
@{ProcessName=OUTLOOK; WS=142602240; CPU=139.2620927}
...

I need it to look like this:

ProcessName           WS                        CPU
iexplore                      378351616         134.6756633
iexplore                      216297472         47.2527029
OUTLOOK                  142602240         139.2620927
...
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McThump
McThump

ASKER

That works. Thanks!