Create an Outlook Appointment with MS GRAPH API and Powershell

Recently, I created an Azure Automation Runbook to keep my Notions Tasks in Sync with my Calendar. I used Graph API to create and update my Outlook Events.

So, we need Powershell and the Following GRAPH API Permission for our Script.

  • Application
    • Calendars.ReadWrite

More Details here: Create event – Microsoft Graph v1.0 | Microsoft Learn

The Script

Here is the full Script with comments. Please remember that the scripts are maintained on GitHub, so I recommend navigating to the latest version of GitHub.

$clientID = "your Client ID"
$Clientsecret = "your Secret"
$tenantID = "your Tenant ID"

$Graph_BaseURL = ""

#Calendar User

#Simple Event Details
$EventSubject = "My GRAPH API Event"
$EventBody = "Thats my awesome GRAPH API Event Body"
$EventLocation = "Microsoft Headquarter"

$EventStart = "2024-02-10T09:00:00"
$EventEnd = "2024-02-10T10:00:00"
$timeZone = "UTC"

#Connect to GRAPH API
$tokenBody = @{
    Grant_Type    = "client_credentials"
    Scope         = ""
    Client_Id     = $clientId
    Client_Secret = $clientSecret
$tokenResponse = Invoke-RestMethod -Uri "$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers = @{
    "Authorization" = "Bearer $($tokenResponse.access_token)"
    "Content-type"  = "application/json"

$SimpleEventJson = @"
  "subject": "$EventSubject",
        "street":"4567 Main St",
  "body": {
    "contentType": "HTML",
    "content": "$($EventBody)"
  "start": {
      "dateTime": "$($EventStart)",
      "timeZone": "$timeZone"
  "end": {
      "dateTime": "$($EventEnd)",
      "timeZone": "$timeZone"

$SimpleEvent = Invoke-RestMethod -Uri "$Graph_BaseURL/users/$TargetUser/calendar/events" -Method POST -Headers $headers -Body $simpleEventJson -ContentType "application/json; charset=utf-8"

The Result


Make sure to get the latest version from GitHub: Seidlm/Microsoft-Graph-API-Examples ( (New Outlook Appointment.ps1)

Michael Seidl aka Techguy
au2mate everything

Leave a Comment

Your email address will not be published. Required fields are marked *