SOLVED

Remove-CalendarEvents cmdlet does not work

Copper 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
I'm not sure, but maybe it's related with date format. It should be mm/dd/yyyy (not with '-')

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

@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.

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

@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...

best response confirmed by kirboronin (Copper Contributor)
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.

(Just added the solution to the reddit thread - WhatAWorld65)
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.
1 best response

Accepted Solutions
best response confirmed by kirboronin (Copper Contributor)
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.

View solution in original post