Solved

How to write formatted get-process output to a file

Posted on 2015-01-12
2
123 Views
Last Modified: 2015-01-12
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
...
0
Comment
Question by:McThump
2 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 40543869
Try
get-process | sort-object WS -descending | select ProcessName, WS, CPU | Format-Table -AutoSize | Out-String | add-content c:\temp\procmem.txt

Open in new window

0
 

Author Closing Comment

by:McThump
ID: 40544638
That works. Thanks!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Synchronize a new Active Directory domain with an existing Office 365 tenant
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now