Share via


Get-ADUser format date properties

Question

Wednesday, July 15, 2015 6:45 AM

For the correct importation into a SQL table I need the date portion of the datetime to be in the yyyy/MM/dd format instead of dd/MM/yyyy for the Created property

Get-ADUser - filter * Created, Department | Select-Object Name, Created, Department ! Export-CSV c:\temp\a.txt

Can this be done for the one liner above?

All replies (1)

Wednesday, July 15, 2015 7:01 AM âś…Answered | 1 vote

Get-ADUser -Filter * -Properties Created, Department | Select-Object Name, @{Name='Created';Expression={$_.Created.ToString("yyyy\/MM\/dd HH:mm:ss")}}, Department | Export-CSV c:\temp\a.txt -NoTypeInformation

This article is useful in case you need to adjust the format:

Formatting Dates and Times