I have a Cmdlet Get-AdUser that I am piping to a select object and in that select running a function on the AccountExpires property to convert the Property Value to a date value.
My question is when the object is output the column heading is no longer friendly and inherits the function used to return the new value. How do I form the statement so a friendly name is output? Was hoping to not have to assemble my own PSObject.
Get-AdUser "some.account" -Properties AccountExpires | select Enabled, Name, $({[datetime]$d =$_.AccountExpires; ConvertTo-Date($d)})
I then get a resulting table header of...
Enabled True [datetime]$d =$_.AccountExpires; ConvertTo-Date($d)
------- ----- ----------------------------------------------------