I'm puzzled by the behavior of the New-MgUserCalendarEvent cmdlet in PowerShell. When I retrieve calendar events using Get-MgUserCalendarEvent, the start and end times are returned in UTC. However, when I try to create a new event with New-MgUserCalendarEvent, it throws an error saying that I must specify a valid TimeZone value. I'm using the exact same start and end times from the Get-MgUserCalendarEvent result, but it still says the TimeZone value is unsupported. Can someone help me understand why this inconsistency exists?
4 Answers
It looks like the confusion stems from the way UTC is recognized. Although UTC is indeed a timezone, New-MgUserCalendarEvent might require it in a different format like 'UTC+00:00'. Just a thought!
I found a workaround! Converting the times returned from Get-MgUserCalendarEvent to my local timezone before passing them into New-MgUserCalendarEvent has worked well. While it’s annoying that I can’t use the exact times, at least there's a solution.
Honestly, this kind of inconsistency is just annoying. UTC should be accepted since that's what is returned. It feels like there's a disconnect in the cmdlets' design.
It sounds frustrating! The error message indicates that the timezone is being interpreted as empty (''). While you expect UTC to be a valid timezone, it seems New-MgUserCalendarEvent might require a specific formatting or identifier for that timezone. It's a common hiccup when dealing with APIs.
I definitely get it! Have you tried specifying the timezone explicitly when calling New-MgUserCalendarEvent? Sometimes the cmdlet needs a full string like 'UTC' instead of just relying on the object you received.
That makes sense! If that's the case, it’s odd that Get-MgUserCalendarEvent doesn't provide it in that format. I'll check if changing the format helps.