Skip to main content

PowerShell and Calculating Column Values

By February 27, 2014September 12th, 2022No Comments

If you have come from a database background it is not uncommon to use calculated column values in your SELECT statements to make more readable reports. The raw data often is not the values that we need to see as humans. this is true in PowerShell as well, when we look at file sizes in Bytes it does  not mean a lot to most of us and the same can be said when we look at the Get-Process cmdlet and the Workingset Memory value which is stored in bytes. In this tutorial we will show the example of using the output from get-process which we can filter and sort and display the ProcessName and Working Set in MB

Get-Process | Sort WorkingSet |
Select ProcessName, @{Name="Memory";Expression{$_.WorkingSet / 1MB}} -Last 5 |Format-Table -AutoSize