Using Update-MgUserEvent in Graph PowerShell

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.

Cmdlet Syntax

Update-MgUserEvent -UserId <String> -EventId <String> -BodyParameter <Hashtable>
  • UserId: The ID of the user whose event is being modified.
  • EventId: The ID of the event to be updated.
  • BodyParameter: A hashtable containing the properties of the event to be updated.

Usage Examples

1. Updating an Offline Meeting

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.

2. Updating an Online Meeting

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.

Cmdlet Tips

  • Strict adherence to hashtable format: When using -BodyParameter, ensure that you follow the Microsoft documentation's structure for the hashtable. Even minor deviations can cause the cmdlet to fail.
  • Testing your updates: Always test your scripts in a non-production environment first, especially when modifying recurring or large-scale events.

Possible Errors & Solutions

Error: The property 'dateTime' does not exist

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

Error: Missing required fields for event

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.

Error: Cannot update an online meeting link.

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.

Use Cases

  • Automating calendar updates: Organizations often deal with multiple team calendars. This cmdlet allows administrators to automate updates to user calendars, such as changing meeting times or updating locations.
  • Updating online meeting links: Suppose your organization is transitioning from one conferencing tool to another (e.g., Zoom to Teams). You can use this cmdlet to update online meeting URLs for upcoming meetings.
  • Bulk event management: Admins can script bulk updates for users' calendars. For instance, in case of daylight savings adjustments, you can update all meeting times to ensure consistency across the organization.

Frequently Asked Questions

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.

You Must Specify Both UserId and EventId to Update an Event

The Update-MgUserEvent cmdlet requires both the UserId (owner of the calendar) and the EventId of the event you wish to update.

If either parameter is missing or invalid, the operation will result in a 400 Bad Request or 404 Not Found error.
Pass Updated Event Fields Using -BodyParameter as a Hashtable

Use the -BodyParameter parameter to pass only the fields you want to update, such as subject, start, end, or location.

Keeping the update payload minimal helps avoid unintentionally overwriting other event details.

Conclusion

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.

Additional Resources:

Graph PowerShell Update-MgUserCalendarEvent Cmdlet Documentation
Microsoft Graph PowerShell Module Documentation
Microsoft Graph API Documentation

Related Articles:

Using Get-MgDirectoryRole in Graph PowerShell
Using Get-MgUserLicenseDetail in Graph PowerShell
Using Find-GraphMgCommand in Graph PowerShell
Connect to Microsoft 365 Using PowerShell
How to Create Bulk Users in Office 365 Using Graph PowerShell?
Create Microsoft 365 Group Using Microsoft Graph PowerShell
Block Microsoft 365 User Using Microsoft Graph PowerShell
Assign Microsoft 365 License Using Graph PowerShell
Microsoft 365 User Management Using Graph PowerShell
Checking Group Membership in Microsoft 365
Bulk Assign Microsoft 365 License
Find Inactive Users in Microsoft 365
Using Powershell Graph Search Query
Using Powershell Graph Filter Query
Using Where-Object In Graph PowerShell
Using Expand Property In Graph PowerShell
Using Select Object In Graph PowerShell
Using -Contains Operator In Graph PowerShell
Add User to Multiple Microsoft 365 Groups Using Graph PowerShell
Get Microsoft 365 User Location Using Graph PowerShell
Import Microsoft 365 Groups from CSV File Using Graph PowerShell
Microsoft 365 Group User Import Using Graph PowerShell

© m365corner.com. All Rights Reserved. Design by HTML Codex