This guide explains how to use the Update-MgUserEvent cmdlet in Microsoft Graph PowerShell to modify calendar events. Learn how to update event details like subject, time, and attendees with practical examples.
The Update-MgUserEvent cmdlet in Microsoft Graph PowerShell is a powerful tool for modifying events in a user's calendar. This cmdlet allows you to update meeting details such as start and end time, location, subject, and even whether the meeting is online or offline. . In this article, we'll explore how to effectively use this cmdlet with examples, possible errors, and use cases.
Update-MgUserEvent -UserId <String> -EventId <String> -BodyParameter <Hashtable>
In this example, we will update an offline meeting's location, start time, and subject.
$eventDetails = @{
subject = "Quarterly Review Meeting"
start = @{
dateTime = "2024-09-10T09:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2024-09-10T10:00:00"
timeZone = "Pacific Standard Time"
}
location = @{
displayName = "Conference Room 101"
}
}
Update-MgUserEvent -UserId "john.doe@contoso.com" -EventId "AAMkAGI2TAAA=" -BodyParameter $eventDetails
In this example, the BodyParameter hashtable contains details about the event's subject, start and end times, and location. This script modifies the event with a new subject and an updated location.
In this example, we will update an existing event to be an online meeting.
$eventDetails = @{
subject = "Project Kickoff"
start = @{
dateTime = "2024-09-12T14:00:00"
timeZone = "Pacific Standard Time"
}
end = @{
dateTime = "2024-09-12T15:30:00"
timeZone = "Pacific Standard Time"
}
isOnlineMeeting = $true
}
Update-MgUserEvent -UserId "jane.smith@contoso.com" -EventId "AAMkAGI2UAAA=" -BodyParameter $eventDetails
Here, the event is updated to an online event by setting the isOnlineMeeting flag to true.
Cause: Incorrect formatting of the start or end sections.
Solution: Ensure both dateTime and timeZone are provided in the correct format (as shown in the examples).
Cause: You did not include required properties like subject, start, or end in the BodyParameter
Solution: Always make sure that the BodyParameter includes all required fields such as start, end, and subject to avoid incomplete event updates.
Cause: You tried to modify a property that is locked for changes (e.g., modifying the join URL after the meeting has started).
Solution: Some properties, like the join URL, cannot be modified after a meeting starts. Ensure that the meeting is in a state where such properties can still be updated.
1. What is Update-MgUserEvent used for?
Update-MgUserEvent is a Microsoft Graph PowerShell cmdlet used to modify calendar events, such as changing their subject, start time, or attendees.
2. Can I add or modify attendees for an event?
Yes, include the attendees property in the request body. Example:
$Body = @{
attendees = @(
@{
emailAddress = @{
address = "newattendee@domain.com"
}
type = "required"
}
)
}
Update-MgUserEvent -UserId "<UserPrincipalName>" -EventId "<EventId>" -BodyParameter $Body
3. What permissions are required to update calendar events?
You need the Calendars.ReadWrite permission in Microsoft Graph PowerShell. Ensure appropriate permissions are granted in Azure AD.
UserId and EventId to Update an EventUpdate-MgUserEvent cmdlet requires both the UserId (owner of the calendar) and the EventId of the event you wish to update.400 Bad Request or 404 Not Found error.
-BodyParameter as a Hashtable-BodyParameter parameter to pass only the fields you want to update, such as subject, start, end, or location.The Update-MgUserEvent cmdlet is a versatile tool for managing Microsoft 365 events. With the ability to modify both online and offline meetings, it can streamline meeting management and ensure that users' calendars remain up-to-date. By adhering to the proper BodyParameter format and following best practices, administrators can confidently manage events without running into errors.
This cmdlet is ideal for organizations looking to automate calendar updates and manage event details efficiently.
© m365corner.com. All Rights Reserved. Design by HTML Codex