# displays to screen ok but not when I export to cSV

**URL:** <https://forums.powershell.org/t/displays-to-screen-ok-but-not-when-i-export-to-csv/1341>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/displays-to-screen-ok-but-not-when-i-export-to-csv/1341 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/displays-to-screen-ok-but-not-when-i-export-to-csv/1341/1 "2011-12-31T18:30:00Z")

</div>

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.`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/displays-to-screen-ok-but-not-when-i-export-to-csv/1341/2 "2024-05-16T20:57:59Z")

</div>

Closed on May 16, 2024, 8:57pm UTC


