Create a Teams 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.

From this, I also tried to send a Teams Appointment Invite with Powershell and Graph API. The result is below.

  • 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 ClientID"
$Clientsecret = "Your Secret"
$tenantID = "your TenantID"

$Graph_BaseURL = ""

#Calendar User

#Invite User
$RecipientName="Ahmed Uzejnovic"
$RecipientType="required" #required, optional

#Teams Event Details
$TeamsEventSubject = "My Teams-GRAPH API Event"
$TeamsEventBody = "Thats my awesome Teams-GRAPH API Event Body"

$TeamsEventStart = "2024-02-25T09:00:00"
$TeamsEventEnd = "2024-02-25T10: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"

$TeamsEventJson = @"
  "subject": "$TeamsEventSubject",
  "isOnlineMeeting": true,
  "onlineMeetingProvider": "teamsForBusiness",
  "attendees": [
      "emailAddress": {
        "name": "$RecipientName"
      "type": "$RecipientType"
  "body": {
    "contentType": "HTML",
    "content": "$($TeamsEventBody)"
  "start": {
      "dateTime": "$($TeamsEventStart)",
      "timeZone": "$timeZone"
  "end": {
      "dateTime": "$($TeamsEventEnd)",
      "timeZone": "$timeZone"

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

The Result


Make sure to get the latest version from GitHub: Seidlm/Microsoft-Teams ( (New Teams Invite.ps1)

Michael Seidl aka Techguy
au2mate everything

Leave a Comment

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