how to add timezone in Exchange Audit cmdlets ?

Copper Contributor

Need to add a custom time with utc timezone in StartDate and Enddate parameters. I have tried the below . are these fine to use ?


Search-UnifiedAuditLog -StartDate ([DateTime]'01/24/2023 17:35:18 PM Z') -EndDate ([DateTime]'01/24/2023 18:35:18 PM Z')


Search-UnifiedAuditLog -StartDate ([DateTime]'01/24/2023 17:35:18 Z') -EndDate ([DateTime]'01/24/2023 18:35:18 Z')

2 Replies
In the first command, you have used the time format hh:mm:ss PM Z, which includes an unnecessary PM indicator as well as the time zone Z.
in Exchange online V3 module , without Z the audit logs takes my local time instead of UTC. this was not the case in V2 module. so, I am using this format .