August 30, 2012

How to use expressions with Select-Object

You can use expressions with a select command to create custom calculated columns. Simply create an Hash table with 2 objects : name, expression.

Here’s a sample :

Get-ChildItem C:\ | Select-Object Name, length, @{Name="Kbytes";Expression={$_.Length / 1Kb}}

No comments:

Post a Comment