-
Notifications
You must be signed in to change notification settings - Fork 187
New-MgUserEvent and New-MgUserCalendarEvent ignore time zone and start/end dates #3271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @12Knocksinna the fix for this issue is on the next release that is still currently on testing. The ETA is by end of next week. However, in case of anything blocking the release, we shall communicate. ![]() ![]() |
@12Knocksinna please confirm with the latest version 2.27.0 |
@timayabi2020 Sorry. Still not working. Event is created in next 30 minute slot. Even worse than before, most of the event detail is missing in the entry posted to the calendar. Here's what is posted: AllowNewTimeProposals : True And here's what Debug says. It looks like many properties are dropped... Absolute Uri: Headers: Body: DEBUG: ============================ HTTP RESPONSE ============================ Status Code: Headers: Body: DEBUG: [CmdletEndProcessing]: - New-MgUserEvent end processing. |
get-module ModuleType Version PreRelease Name ExportedCommands Script 2.27.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-M… |
@12Knocksinna I also got the same error on first time installation and immediately started using it. However, after restarting the PowerShell session I was able to get the correct payload. Please restart the session and let me know if you are still experiencing the same. |
I exited PowerShell, restarted a session, connected to Graph in app-only mode (make sure of permissions) and reran the script. New-MgUserEvent created an empty event, the Graph request created the expected event. Both used the same payload. |
There are other issues with the calendar events cmdlets. The Update-MgUserEvent cmdlet doesn't seem to work when adding attendees and I cannot get the New-MgUserEventAttachment cmdlet to work despite using the exact example cited in the documentation https://learn.microsoft.com/en-us/graph/api/event-post-attachments?view=graph-rest-1.0&tabs=powershell, Maybe the whole area of calendar events cmdlets need some TLC? |
I see different behavior with the Graph request and the cmdlet. The graph request works with this payload containing 3 attendees: $EventDetails = @{} array with details of event participants$ParticipantsArray = @( Create hash tables for each participant$EventAttendees = @()
} Add the attendees to the event$EventDetails.Add("attendees", $EventAttendees) $Uri = ("https://graph.microsoft.com/v1.0/users/{0}/events/{1}" -f $UserId, $NewEvent.Id) Using the same payload, Update-MgUserEvent doesn't update the attendees. $EventDetails Name Value attendees {System.Collections.Hashtable, System.Collections.Hashtable, System.Collections.Hashtab… Update-MgUserEvent -UserId $UserId -EventId $NewEvent.Id -BodyParameter $EventDetails -debug Confirm HTTP Method: Headers: Body: DEBUG: ============================ HTTP RESPONSE ============================ Status Code: Headers: Body: DEBUG: [CmdletEndProcessing]: - Update-MgUserEvent end processing. The Experts Conference (TEC) 2025 – Best Conference Ever AAMkADJjNjgyOWU3LWU2OWQtNDE0ZC05NjY1LTViYWQ0N2M2Njk5MgBGAAAAA…# It seems like the attendees information is simply ignored. What kind of payload did you use to update the attendees? |
This is the payload I used
but let me try adding three at a go and see |
Your payload didn't work for me... $MyAttendee = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphAttendee]::new() Update-MgUserEvent -UserId $UserId -EventId $NewEvent.Id -BodyParameter $MyAttendee -debug Body: Looks like the cmdlet is a little flaky... Or I am a little flaky |
Doesn't work with pdate-MgUserEvent -UserId $UserId -EventId $NewEvent.Id -Attendees $MyAttendee either... But no error. |
The calendar module is loaded... I don't think it's that. Maybe I shall try a reboot, just to see. |
After rebooting the PC, this worked: Update-MgUserEvent -UserId $UserId -EventId $NewEvent.Id -Attendees $MyAttendee The way I read the documentation is that an array of attendees is passed in a hash table when multiple attendees are involved. So I tried with: $MyAttendee = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphAttendee]::new() $MyAttendee1 = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphAttendee]::new() $MyAttendee2 = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphAttendee]::new() [array]$EventAttendees = $MyAttendee, $MyAttendee1, $MyAttendee2 Update-MgUserEvent -UserId $UserId -EventId $NewEvent.Id -Attendees $EventAttendees And that worked... Weird that the reboot seemed to have cured the problem. |
Using the same array with the Graph request doesn't work. $Ev = @{} {"error":{"code":"RequestBodyRead","message":"A null value was found for the property named 'dateTime', which has the expected type 'microsoft.graph.dateTime[Nullable=False]'. The expected type 'microsoft.graph.dateTime[Nullable=False]' does not allow null values."}} Looks like it's missing a property that needs to be added when you declare the attendee to be of Microsoft.Graph.PowerShell.Models.MicrosoftGraphAttendee. Maybe it's looking for a value for proposedNewTime, but that doesn't seem to be necessary. |
So there's some work to be done to make everything function consistently across the Graph request and cmdlet. And you couldn't add an attachment to an event either... that's interesting. |
Describe the bug
This bug might be linked to #3223
If you run the New-MgUserEvent or New-MgUserCalendarEvent cmdlets to create a new event in a calendar, the cmdlets ignore the time zone and start and date passed in the payload and create an event that's in the next 30-minute slot in the target calendar.
Expected behavior
Obviously, calendar events should be scheduled for when they're supposed to happen.
How to reproduce
$UserId = (Get-MgUser -UserId (Get-MgContext).Account).Id
Create simple calendar appointment
$EventBody = @{}
$EventBody.Add("contentType", "HTML")
$EventBody.Add("content", "The TEC 2025 comference event starts with registration and breakfast at 8:30AM. The first session will commence at 9:30AM")
$EventStart = @{}
$EventStart.Add("dateTime", "2025-09-30T09:00:00")
$EventStart.Add("timeZone", "Central Standard Time")
$EventEnd = @{}
$EventEnd.Add("dateTime", "2025-10-01T17:00:00")
$EventEnd.Add("timeZone", "Central Standard Time")
$EventLocation = @{}
$EventLocation.Add("displayName", "Minneapolis")
$Event = @{}
$Event.Add("subject", "The Experts Conference (TEC) 2025")
$Event.Add("body", $EventBody)
$Event.Add("start", $EventStart)
$Event.Add("end", $EventEnd)
$Event.Add("location", $EventLocation)
$Event.Add("allowNewTimeProposals", $true)
$Event.Add("transactionId", (New-Guid))
$NewEvent = New-MgUserEvent -UserId $userId -BodyParameter $Event
Event is scheduled. But running the cmdlet at 17:20 on 14 April, the created event started at 17:30 instead of 9AM on September 30. You can see from the debug output that the start and end dates have been changed and the timezone switched from CST to UTC.
SDK Version
2.26.1
Latest version known to work for scenario above?
Unknown
Known Workarounds
Use the Graph API request, which works perfectly.
Debug output
Click to expand log
```DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://graph.microsoft.com/v1.0/users/eff4cd58-1bb8-4899-94de-795f656b4a18/events
Headers:
FeatureFlag : 00000003
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.26100; en-IE),PowerShell/7.5.0
SdkVersion : graph-powershell/2.26.1
client-request-id : 669bd0ea-a50c-4bef-b479-6a1195d7b0aa
Accept-Encoding : gzip,deflate,br
Body:
{
"subject": "The Experts Conference (TEC) 2025",
"transactionId": "bf25b696-fc44-4715-9c1d-7e572264d0e5"
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
Created
Headers:
Cache-Control : private
Location : https://graph.microsoft.com/v1.0/users('eff4cd58-1bb8-4899-94de-795f656b4a18')/events('AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNABGAAAAAAB_7ILpFNx8TrktaK8VYWerBwBe9CuwLc2fTK7W46L1SAp9AAAA2lHQAAA3tTkMTDKYRI6zB9VW59QNAAgkhLM6AAA=')
Strict-Transport-Security : max-age=31536000
request-id : 548845bd-dd7b-4357-9e11-0a9740b43d16
client-request-id : 669bd0ea-a50c-4bef-b479-6a1195d7b0aa
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"North Europe","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"DB1PEPF0001F9BD"}}
Date : Mon, 14 Apr 2025 16:21:11 GMT
Body:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('eff4cd58-1bb8-4899-94de-795f656b4a18')/events/$entity",
"@odata.etag": "W/"N7U5DEwymESOswfVVufUDQAIICsq6Q=="",
"id": "AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNABGAAAAAAB_7ILpFNx8TrktaK8VYWerBwBe9CuwLc2fTK7W46L1SAp9AAAA2lHQAAA3tTkMTDKYRI6zB9VW59QNAAgkhLM6AAA=",
"createdDateTime": "2025-04-14T16:21:11.2569062Z",
"lastModifiedDateTime": "2025-04-14T16:21:11.3283024Z",
"changeKey": "N7U5DEwymESOswfVVufUDQAIICsq6Q==",
"categories": [],
"transactionId": "bf25b696-fc44-4715-9c1d-7e572264d0e5",
"originalStartTimeZone": "UTC",
"originalEndTimeZone": "UTC",
"iCalUId": "040000008200E00074C5B7101A82E00800000000C8DE473C59ADDB01000000000000000010000000111F84A0F73D9947A66167713D47E13D",
"uid": "040000008200E00074C5B7101A82E00800000000C8DE473C59ADDB01000000000000000010000000111F84A0F73D9947A66167713D47E13D",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "The Experts Conference (TEC) 2025",
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"webLink": "https://outlook.office365.com/owa/?itemid=AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNABGAAAAAAB%2B7ILpFNx8TrktaK8VYWerBwBe9CuwLc2fTK7W46L1SAp9AAAA2lHQAAA3tTkMTDKYRI6zB9VW59QNAAgkhLM6AAA%3D&exvsurl=1&path=/calendar/item",
"onlineMeetingUrl": null,
"isOnlineMeeting": false,
"onlineMeetingProvider": "unknown",
"allowNewTimeProposals": true,
"occurrenceId": null,
"isDraft": false,
"hideAttendees": false,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"body": {
"contentType": "html",
"content": "<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta name="Generator" content="Microsoft Exchange Server">\r\n\r\n<style></style>\r\n\r\n<font size="2"><span style="font-size:11pt;"><div class="PlainText"> \r\n\r\n\r\n"
},
"start": {
"dateTime": "2025-04-14T16:30:00.0009324",
"timeZone": "UTC"
},
"end": {
"dateTime": "2025-04-14T17:00:00.0009324",
"timeZone": "UTC"
},
"location": {
"displayName": "",
"locationType": "default",
"uniqueIdType": "unknown",
"address": {},
"coordinates": {}
},
"locations": [],
"recurrence": null,
"attendees": [],
"organizer": {
"emailAddress": {
"name": "Tony Redmond",
"address": "[email protected]"
}
},
"onlineMeeting": null
}
DEBUG: [CmdletEndProcessing]: - New-MgUserEvent end processing.
The text was updated successfully, but these errors were encountered: