I'm aware that we can specify a comma-separated string[] of properties in a variable to the Select-Object -Property
parameter. However, I'm trying to include calculated properties in that variable. Tried adding it by enclosing them in single-quotes / double-quotes like,
$selectProps = "distinguishedname", '@{n="lastlogontimestamp";e={[datetime]::FromFileTime($_.lastlogontimestamp).ToString()}}'
and
$selectProps = "distinguishedname","@{n=`"lastlogontimestamp`";e={[datetime]::FromFileTime(`$_.lastlogontimestamp).ToString()}}"
but to no avail. Any help will be much appreciated.