PowerTip: Creating a Custom Number Display

Summary: Learn how to create a custom number display.

Question: How do I display a “calculated value” (megabytes instead of bytes) from a WMI query when piping data into a Format-Table cmdlet?

Answer: Create a hash table where you want to display the data, and perform the calculation inside curly brackets, and then assign the results to the expression parameter as shown here:

gwmi win32_logicaldisk -Filter “drivetype=3″ | ft -Property name, @{ Label=”freespace”; expression={$_.freespace/1MB}}