This project facilitates importing .ics
calendar files into Microsoft 365 (M365) group calendars using PowerShell and the Microsoft Graph API. This approach addresses the challenge that direct copying of .ics
files to M365 group calendars is not supported.
The original script was derived from this Spiceworks community post. While M365 might seem to allow copying .ics
files to group calendars, these entries do not persist and are eventually removed, as the functionality has effectively been patched out.
This script leverages the Microsoft Graph API to overcome these limitations, providing a reliable way to import .ics
files.
Before using the script, you must configure your Azure AD application and gather necessary credentials.
- Navigate to the Azure AD App Registrations.
- Create a new app registration:
- Provide a name.
- Select Accounts in this organizational directory only (Single tenant).
- Click Register.
- Add a redirect URI:
- Click Add a platform and select Web.
- Set
http://localhost
as the Redirect URL. - Set
https://localhost
as the Logout URI.
- Add API permissions:
- Select Microsoft Graph > Delegated permissions.
- Search for
group.readwrite.all
and enable it. - Grant admin consent for the permission.
- Modify the app manifest:
- Set
"allowPublicClient": null
to"allowPublicClient": true
.
- Set
- Generate client credentials:
- Create a Client Secret and copy its value immediately.
- Navigate to Azure AD Groups.
- Locate the desired M365 group.
- Copy the Object ID (this will serve as the
GroupId
).
Before running the script, update the following variables:
#############
# Variables #
#############
# Path to the ICS file
$ics = "C:\temp\calendar\calendar.ics"
# Graph API token credentials
$TenantName = "<tenant>.onmicrosoft.com"
$ClientId = "<your-client-id>"
$ClientSecret = "<your-client-secret>"
# Office 365 Group ID
$GroupId = "<your-group-id>"
Ensure you have PowerShell installed with the required modules (e.g., Microsoft.Graph). Save the script to a .ps1 file. Open PowerShell and execute the script:
`.\Import-M365GroupCalendar.ps1
Guide to Authenticating the API with PowerShell
Directly copying .ics files to M365 group calendars is not supported. This script provides a workaround by programmatically interacting with the M365 group calendar via the Graph API.