SOLVED

Remove-CalendarEvents cmdlet does not work

%3CLINGO-SUB%20id%3D%22lingo-sub-1005190%22%20slang%3D%22en-US%22%3ERemove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005190%22%20slang%3D%22en-US%22%3E%3CP%3EI%20used%20that%20several%20times%20and%20had%20a%20cheat-sheet%20with%20commands%20to%20clean%20recurring%20meetings%20of%20persons%20who%20has%20left%20the%20company.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20did%20not%20work%20the%20last%20time%2C%20returning%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ERemove-CalendarEvents%20-Identity%20name.lastname%40company.com%20-CancelOrganizedMeetings%20-PreviewOnly%0A%0AMicrosoft.Exchange.Entities.DataModel.InvalidRequestException%3A%20Your%20request%20can't%20be%20completed.%20The%20range%20between%20the%20start%20and%20end%20dates%20is%20greater%20than%20the%20allowed%20range.%20Maximum%0Anumber%20of%20days%3A%201825%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20tried%20to%20specify%20time%20period%2C%20I%20got%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ERemove-CalendarEvents%20-Identity%20name.lastname%40company.com%20-CancelOrganizedMeetings%20-QueryStartDate%204-11-2019%20-PreviewOnly%0A%0ASystem.Management.Automation.ParentContainsErrorRecordException%3A%20Cannot%20process%20argument%20transformation%20on%20parameter%20'QueryStartDate'.%20Cannot%20convert%20value%20%2211.4.2019%200.00.00%22%20to%20t%0Aype%20%22Microsoft.Exchange.ExchangeSystem.ExDateTime%22.%20Error%3A%20%22String%20was%20not%20recognized%20as%20a%20valid%20DateTime.%22.%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAgain%2C%20that%20was%20working%20couple%20months%20ago%20just%20fine.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1005190%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eoffice%20365%20calendars%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1005995%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005995%22%20slang%3D%22en-US%22%3EI'm%20not%20sure%2C%20but%20maybe%20it's%20related%20with%20date%20format.%20It%20should%20be%20mm%2Fdd%2Fyyyy%20(not%20with%20'-')%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006193%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006193%22%20slang%3D%22en-US%22%3E%3CP%3EJust%20use%20%22neutral%22%20notation%20such%20as%20%224%20Nov%202019%22.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007502%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007502%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F119994%22%20target%3D%22_blank%22%3E%40Ricardo%20Viana%3C%2FA%3E%26nbsp%3Byes%2C%20I%20thought%20about%20that%20weird%20us%20format%20too%2C%20but%20there%20is%20no%20difference%20between%204%20Nov%20and%2011%20April%2C%20right%3F%3C%2FP%3E%3CP%3ETried%20different%20dividers%3A%20%2C.%2F-%20with%20same%20error%20message%3A%20%22Cannot%20convert%20value%20%2211.4.2019%200.00.00%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3Bthat%20format%20%224%20Nov%202019%22%20returns%20completely%20the%20same%20error%3A%20%22Cannot%20convert%20value%20%224.11.2019%200.00.00%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%3A%20that%20was%20warking%20even%20without%26nbsp%3B-QueryStartDate%20parameter.%20And%20I%20can't%20find%20anything%20in%20MS%20documentation%20about%20any%20changes.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007654%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007654%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20looks%20like%20you%20now%20need%20QueryStartDate%20and%20QueryWindowInDays%20(max%20value%201825).%20As%20you%20mentioned%20there%20is%20no%20documentation%20about%20this%20change%20and%20the%20Remove-CalendarEvents%20is%20not%20updated%20as%20well.%3CBR%20%2F%3E%3CBR%20%2F%3ERan%20it%20like%20this%20and%20it%20worked%3A%3CBR%20%2F%3ERemove-CalendarEvents%20-Identity%20user%40domain.com%20-QueryStartDate%2011%2F04%2F2018%20-QueryWindowInDays%201825%20-CancelOrganizedMeetings%20-PreviewOnly%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007972%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007972%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F119994%22%20target%3D%22_blank%22%3E%40Ricardo%20Viana%3C%2FA%3E%26nbsp%3Badding%26nbsp%3B%3CSPAN%3E-QueryWindowInDays%20parameter%20does%20not%20change%20problem%2C%20that%20server%20does%20not%20accept%20date%20not%20in%20normal%20dd%2Fmm%2Fyyyy%2C%20nor%20in%20weird%20mm%2Fdd%2Fyyyy%2C%20nor%20in%20any%20other%20format.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ESomeone%20else%20met%20that%20problem%20and%20in%20discussion%20with%20MS%20support%2C%20I%20will%20follow%20this%20thread%20in%20hope%20of%20solution%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.reddit.com%2Fr%2FPowerShell%2Fcomments%2Fdvbqn2%2Fgetting_an_error_when_running_removecalendarevents%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.reddit.com%2Fr%2FPowerShell%2Fcomments%2Fdvbqn2%2Fgetting_an_error_when_running_removecalendarevents%2F%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1033488%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1033488%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F456577%22%20target%3D%22_blank%22%3E%40kirboronin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20had%20the%20exact%20same%20problem.%3C%2FP%3E%3CP%3EThen%20i%20noticed%20the%20error%20message%20always%20translating%20whatever%20timedate-string%20I%20attempted%20to%20use%20to%20my%20locale.%3C%2FP%3E%3CP%3EThe%20error%20was%20introduced%20by%20some%20Microsoft%20Engineer%20unable%20to%20take%20into%20account%20the%20existence%20of%20other%20languages%20but%20US-English.%3C%2FP%3E%3CP%3ETry%20setting%20your%20region%20settings%20in%20the%20OS%20to%20US%20English.%20Then%20start%20a%20new%20powershell.%20Connect%20to%20Office%20365.%20Issue%20the%20command.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1035458%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1035458%22%20slang%3D%22en-US%22%3E(Just%20added%20the%20solution%20to%20the%20reddit%20thread%20-%20WhatAWorld65)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1035460%22%20slang%3D%22en-US%22%3ERe%3A%20Remove-CalendarEvents%20cmdlet%20does%20not%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1035460%22%20slang%3D%22en-US%22%3EThanks!%20But%20I%20solve%20it%20just%20by%20adding%20-QueryWindowInDays%201825%3CBR%20%2F%3EWe%20have%20limit%20of%20365%20days%20for%20booking%20meeting%20rooms%2C%20so%20I%20hope%2C%205%20years%20is%20enough.%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I used that several times and had a cheat-sheet with commands to clean recurring meetings of persons who has left the company.

 

That did not work the last time, returning error:

 

Remove-CalendarEvents -Identity name.lastname@company.com -CancelOrganizedMeetings -PreviewOnly

Microsoft.Exchange.Entities.DataModel.InvalidRequestException: Your request can't be completed. The range between the start and end dates is greater than the allowed range. Maximum
number of days: 1825

 

When I tried to specify time period, I got this:

 

Remove-CalendarEvents -Identity name.lastname@company.com -CancelOrganizedMeetings -QueryStartDate 4-11-2019 -PreviewOnly

System.Management.Automation.ParentContainsErrorRecordException: Cannot process argument transformation on parameter 'QueryStartDate'. Cannot convert value "11.4.2019 0.00.00" to t
ype "Microsoft.Exchange.ExchangeSystem.ExDateTime". Error: "String was not recognized as a valid DateTime.". 

 

 

Again, that was working couple months ago just fine.

8 Replies
Highlighted
I'm not sure, but maybe it's related with date format. It should be mm/dd/yyyy (not with '-')
Highlighted

Just use "neutral" notation such as "4 Nov 2019".

Highlighted

@Ricardo Viana yes, I thought about that weird us format too, but there is no difference between 4 Nov and 11 April, right?

Tried different dividers: ,./- with same error message: "Cannot convert value "11.4.2019 0.00.00"

 

@Vasil Michev that format "4 Nov 2019" returns completely the same error: "Cannot convert value "4.11.2019 0.00.00"

 

The problem is: that was warking even without -QueryStartDate parameter. And I can't find anything in MS documentation about any changes.

Highlighted

It looks like you now need QueryStartDate and QueryWindowInDays (max value 1825). As you mentioned there is no documentation about this change and the Remove-CalendarEvents is not updated as well.

Ran it like this and it worked:
Remove-CalendarEvents -Identity user@domain.com -QueryStartDate 11/04/2018 -QueryWindowInDays 1825 -CancelOrganizedMeetings -PreviewOnly

Highlighted

@Ricardo Viana adding -QueryWindowInDays parameter does not change problem, that server does not accept date not in normal dd/mm/yyyy, nor in weird mm/dd/yyyy, nor in any other format.

 

Someone else met that problem and in discussion with MS support, I will follow this thread in hope of solution: https://www.reddit.com/r/PowerShell/comments/dvbqn2/getting_an_error_when_running_removecalendareven...

Highlighted
Solution

@kirboronin 

I had the exact same problem.

Then i noticed the error message always translating whatever timedate-string I attempted to use to my locale.

The error was introduced by some Microsoft Engineer unable to take into account the existence of other languages but US-English.

Try setting your region settings in the OS to US English. Then start a new powershell. Connect to Office 365. Issue the command.

Highlighted
(Just added the solution to the reddit thread - WhatAWorld65)
Highlighted
Thanks! But I solve it just by adding -QueryWindowInDays 1825
We have limit of 365 days for booking meeting rooms, so I hope, 5 years is enough.