Display file size in KB - Calculated Properties

suggest change

Let’s consider the below snippet,

Get-ChildItem -Path C:\MyFolder | Select-Object Name, CreationTime, Length

It simply output the folder content with the selected properties. Something like,

What if I want to display the file size in KB ? This is where calcualted properties comes handy.

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

Which produces,

The Expression is what holds the calculation for calculated property. And yes, it can be anything!

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents