Calculated Property
noun
say it: “KAL-kyuh-lay-tid PROP-er-tee” /ˈkælkjəleɪtɪd ˈprɑpərti/
In PowerShell, a column you add to Select-Object yourself, with a name and a small piece of code that works out its value.
What is a calculated property in PowerShell?
A calculated property is a column you make yourself in Select-Object: a hashtable, @{ Name = ...; Expression = { ... } }. Name is the heading, and the Expression script block works out the value for each object, with $_ for this item.
Get-ChildItem videos | Select-Object Name, @{ Name = 'SizeMB'; Expression = { [math]::Round($_.Length / 1MB, 1) } }
In a sentence
- “Maya added a calculated property called SizeMB, so the sizes read in megabytes instead of bytes.”
- “A calculated property is a hashtable with a Name and an Expression.”
Level: Journeyman · More PowerShell terms at this level
Updated