Remove-CalendarEvents on Exchange Online throws: "String was not recognized as a valid DateTime!

%3CLINGO-SUB%20id%3D%22lingo-sub-2258438%22%20slang%3D%22en-US%22%3ERemove-CalendarEvents%20on%20Exchange%20Online%20throws%3A%20%22String%20was%20not%20recognized%20as%20a%20valid%20DateTime!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2258438%22%20slang%3D%22en-US%22%3E%3CP%3ESeems%20that%20problem%20appears%20only%20for%20Remove-CalendarEvents%20cmdlet%20when%20we%20set%20its%20QueryStartDate%20parameter.%3CBR%20%2F%3EWe%20have%20tested%20Set-Mailbox%20with%20StartDateForRetentionHold%20and%20EndDateForRetentionHold%20parameters%20and%20Set-MailboxAutoReplyConfiguration%20with%20-StartTime%20and%20-EndTime%20and%20these%20cmdlets%20worked%20just%20fine.%20For%20all%20cmdlets%20we%20have%20specified%20dates%20as%20object%20of%20DateTime%20type%20but%20error%20appears%20only%20for%20Remove-CalendarEvents.%3CBR%20%2F%3EProblem%20happens%20on%20different%20time%20formats%2C%20we%20have%20tested%20United%20Kingdom(dd%2FMM%2Fyyyy)%20and%20Unkrainian(dd.MM.yyyy)%20formats%20and%20it%20seems%20that%20problem%20appears%20when%20day%20part%20is%20in%20the%20first%20place.%20Everything%20is%20ok%20when%20we%20using%20United%20Sates(M%2Fd%2Fyyyy)%20format.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20tried%20creating%20dates%20in%20different%20ways%3A%3CBR%20%2F%3E%24date%20%3D%20Get-Date%20-Date%20%2227.08.2020%22%3CBR%20%2F%3E%24date%20%3D%20%5BSystem.DateTime%5D%3A%3AParse(%2227.08.2020%22)%3CBR%20%2F%3EWe%20even%20tried%20to%20specify%20the%20kind%20of%20days%20created%2C%20but%20that%20didn't%20change%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E**Full%20error%3A**%3CBR%20%2F%3EError%20on%20proxy%20command%20'Remove-CalendarEvents%20-Identity%3A''%20-CancelOrganizedMeetings%3A%24True%3CBR%20%2F%3E-Confirm%3A%24False%20-QueryStartDate%3A'27%2F08%2F2020%2000%3A00%3A00'%20-QueryWindowInDays%3A'1825''%20to%20server%3CBR%20%2F%3EVI1PR06MB5152.eurprd06.prod.outlook.com%3A%20Server%20version%2015.20.3999.0000%2C%20Proxy%20method%20PSWS%3A%3CBR%20%2F%3ECmdlet%20error%20with%20following%20error%20message%3A%3CBR%20%2F%3ESystem.Management.Automation.ParentContainsErrorRecordException%3A%20Cannot%20process%20argument%20transformation%20on%20parameter%3CBR%20%2F%3E'QueryStartDate'.%20Cannot%20convert%20value%20%2227%2F08%2F2020%2000%3A00%3A00%22%20to%20type%20%22Microsoft.Exchange.ExchangeSystem.ExDateTime%22.%20Error%3A%3CBR%20%2F%3E%22String%20was%20not%20recognized%20as%20a%20valid%20DateTime.%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E**Environment%3A**%3CBR%20%2F%3E**PSVersion%3A**%205.1.17763.1490%3CBR%20%2F%3E**PSEdition%3A**%20Desktop%3CBR%20%2F%3E**PSCompatibleVersions%3A**%20%7B1.0%2C%202.0%2C%203.0%2C%204.0...%7D%3CBR%20%2F%3E**BuildVersion%3A**%2010.0.17763.1490%3CBR%20%2F%3E**CLRVersion%3A**%204.0.30319.42000%3CBR%20%2F%3E**WSManStackVersion%3A**%203.0%3CBR%20%2F%3E**PSRemotingProtocolVersion%3A**%202.3%3CBR%20%2F%3E**SerializationVersion%3A**%201.1.0.1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tested%20this%20case%20on%20another%20computer%20and%20it%20wasn't%20reproduced.%20I%20don't%20fully%20sure%20that%20problem%20is%20only%20in%20version%20of%20powershell%20but%20I%20have%20performed%20the%20same%20actions%20as%20on%20the%20first%20computer.%3CBR%20%2F%3E**Environment%3A**%3CBR%20%2F%3E**PSVersion%3A**%205.1.17134.407%3CBR%20%2F%3E**PSEdition%3A**%20Desktop%3CBR%20%2F%3E**PSCompatibleVersions%3A**%20%7B1.0%2C%202.0%2C%203.0%2C%204.0...%7D%3CBR%20%2F%3E**BuildVersion%3A**%2010.0.17134.407%3CBR%20%2F%3E**CLRVersion%3A**%204.0.30319.42000%3CBR%20%2F%3E**WSManStackVersion%3A**%203.0%3CBR%20%2F%3E**PSRemotingProtocolVersion%3A**%202.3%3CBR%20%2F%3E**SerializationVersion%3A**%201.1.0.1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2258438%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Seems that problem appears only for Remove-CalendarEvents cmdlet when we set its QueryStartDate parameter.
We have tested Set-Mailbox with StartDateForRetentionHold and EndDateForRetentionHold parameters and Set-MailboxAutoReplyConfiguration with -StartTime and -EndTime and these cmdlets worked just fine. For all cmdlets we have specified dates as object of DateTime type but error appears only for Remove-CalendarEvents.
Problem happens on different time formats, we have tested United Kingdom(dd/MM/yyyy) and Unkrainian(dd.MM.yyyy) formats and it seems that problem appears when day part is in the first place. Everything is ok when we using United Sates(M/d/yyyy) format.

 

We tried creating dates in different ways:
$date = Get-Date -Date "27.08.2020"
$date = [System.DateTime]::Parse("27.08.2020")
We even tried to specify the kind of days created, but that didn't change anything.

 

**Full error:**
Error on proxy command 'Remove-CalendarEvents -Identity:'' -CancelOrganizedMeetings:$True
-Confirm:$False -QueryStartDate:'27/08/2020 00:00:00' -QueryWindowInDays:'1825'' to server
VI1PR06MB5152.eurprd06.prod.outlook.com: Server version 15.20.3999.0000, Proxy method PSWS:
Cmdlet error with following error message:
System.Management.Automation.ParentContainsErrorRecordException: Cannot process argument transformation on parameter
'QueryStartDate'. Cannot convert value "27/08/2020 00:00:00" to type "Microsoft.Exchange.ExchangeSystem.ExDateTime". Error:
"String was not recognized as a valid DateTime.".

 

**Environment:**
**PSVersion:** 5.1.17763.1490
**PSEdition:** Desktop
**PSCompatibleVersions:** {1.0, 2.0, 3.0, 4.0...}
**BuildVersion:** 10.0.17763.1490
**CLRVersion:** 4.0.30319.42000
**WSManStackVersion:** 3.0
**PSRemotingProtocolVersion:** 2.3
**SerializationVersion:** 1.1.0.1

 

I've tested this case on another computer and it wasn't reproduced. I don't fully sure that problem is only in version of powershell but I have performed the same actions as on the first computer.
**Environment:**
**PSVersion:** 5.1.17134.407
**PSEdition:** Desktop
**PSCompatibleVersions:** {1.0, 2.0, 3.0, 4.0...}
**BuildVersion:** 10.0.17134.407
**CLRVersion:** 4.0.30319.42000
**WSManStackVersion:** 3.0
**PSRemotingProtocolVersion:** 2.3
**SerializationVersion:** 1.1.0.1

 

0 Replies