Powershell export date data to CSV.

Kalaimani Thirupathi 411 Reputation points
2021-09-02T15:28:12.607+00:00

Dear All,

I'm not able to export the date and time using Powershell. Kindly help me with this, please.

PS C:\> $Output
WeeklySchedule DaysOfTheWeek : {Wednesday, Saturday, Friday, Sunday}
MonthlySchedule RetentionScheduleWeekly DaysOfTheWeek : {Wednesday, Sunday}
MonthlySchedule RetentionScheduleWeekly WeeksOfTheMonth : {Last, First}
YearlySchedule MonthsOfYear : {January} :
YearlySchedule RetentionScheduleWeekly DaysOfTheWeek : {Sunday}
YearlySchedule RetentionScheduleWeekly WeeksOfTheMonth : {Last}

128812-image.png

but when I export to csv getting the below error

128759-image.png

Windows for business Windows Server User experience PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,916 Reputation points
    2021-09-03T12:42:14.627+00:00

    Hello @Kalaimani Thirupathi

    Have you tried:

    $CurrentDate = Get-Date
    $CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss')
    Get-CsAdUser -OU "OU=OUName,OU=OUName,DC=this,dc=is,dc=my,dc=domain" |
    Where-Object {$.Name -like "AA*" -or $.Name -like "BB*" -and $.Enabled -ne $TRUE } |
    Export-Csv -Path "D:\EnableLyncUsers\ExportsByDate\AABBAccounts
    $CurrentDate.csv"

    It is not very clear why or how you want to retrieve date and time, but a bit more explaination could help the community to guide you.

    Hope this code helps you,
    Best regards,

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.