displays to screen ok but not when I export to cSV

by Christopher.Ellis at 2013-02-22 11:53:37

get-aduser -filter * -property lastlogontimestamp | ft -property Name, {[System.DateTime]::FromFileTime($_.lastlogontimestamp)} -A

This commmand displays to screen exactly as I want - however, when i export to CSV - the format is wrong, it is wrong because i did the format then exported to CSV, how do I get what is displayed on screen (the date format is the critical aspect) to display properly in the format ? I require a legible date format when I export to CSV
I am getting closed to my resolve because of persons who contributed in this forum, therefore thank you
by kittH at 2013-02-22 12:47:57
You can add an expression to the Select statement:

Get-ADUser -filter * -Properties lastLogonTimeStamp | Select Name, @{Name="LastLogonTimeStamp";Expression={[System.DateTime]]

That will leave it as an object that you should be able to cleanly export to a CSV.