The New-MgUserCalendarGroup cmdlet allows you to create a new calendar group for a specific user in Microsoft 365. Calendar groups are helpful for organizing multiple calendars, making it easier to manage and view related events. This article covers the syntax, usage examples, tips, common errors, and use cases for this cmdlet.
New-MgUserCalendarGroup -UserId <String> -BodyParameter <IMicrosoftGraphCalendarGroup>
This example creates a new calendar group named "Project Calendars" for a user.
$params = @{
name = "Project Calendars"
}
New-MgUserCalendarGroup -UserId "jdoe@contoso.com" -BodyParameter $params
This example demonstrates creating multiple calendar groups for a user by looping through a list of group names.
$calendarGroups = @("Team Meetings", "Project Deadlines", "Personal Tasks")
foreach ($group in $calendarGroups) {
$params = @{
name = $group
}
New-MgUserCalendarGroup -UserId "jdoe@contoso.com" -BodyParameter $params
}
This example shows how to create multiple calendar groups from a CSV file containing calendar group names.
CSV File (CalendarGroups.csv) Content:
GroupName
Team Meetings
Project Deadlines
Personal Tasks
PowerShell Script:
$calendarGroups = Import-Csv -Path "C:\Path\To\CalendarGroups.csv"
foreach ($group in $calendarGroups) {
$params = @{
name = $group.GroupName
}
New-MgUserCalendarGroup -UserId "jdoe@contoso.com" -BodyParameter $params
}
Locating the Newly Created Calender Groups
Newly created calendar groups would be present at the bottom-right of Calendars tab in Microsoft Outlook.
Cause: The -UserId parameter was provided with an incorrect or non-existent user ID.
Solution: Verify that the -UserId is correct. You can use the Get-MgUser cmdlet to confirm the user ID.
Cause: The -BodyParameter hashtable is incorrectly formatted or missing required properties.
Solution: Ensure that the hashtable includes valid properties such as name. Refer to the Microsoft Graph documentation for the correct format.
Cause: The user running the script does not have sufficient permissions to create a calendar group.
Solution: Ensure the user has the necessary permissions, such as Calendars.ReadWrite or Calendars.ReadWrite.Shared. You may need to grant these permissions via Azure AD.
The New-MgUserCalendarGroup cmdlet is a powerful tool for managing calendar groups within Microsoft 365. By understanding its syntax, usage, and potential errors, you can efficiently create and organize calendar groups for yourself or others within your organization. Whether for personal use, team management, or department-wide event organization, this cmdlet streamlines the process of managing multiple calendars.
© m365corner.com. All Rights Reserved. Design by HTML Codex