Calculated properties in Select-Object

Calculated properties can be used in Select-Object to format results in a particular way:

Get-ADUser | select GivenName, @{Name='Hello', Expression={'World {0}' -f $_.Surname}}

Shortcuts of n and e can be used for the keys, i.e.

Get-ADUser | select GivenName, @{n='Hello', e={'World {0}' -f $_.Surname}}

See also

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_calculated_properties

Left-click: follow link, Right-click: select node, Scroll: zoom
x