SharePoint Online: Add Calendar Item using PowerShell

Requirement: Add Calendar event in SharePoint Online using PowerShell

PowerShell to Add calendar event in sharepoint online

PowerShell to Add New Item in SharePoint Online Calendar

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$SiteURL = ""
$CalendarName = "Team Calendar"

Try {
    #Setup Credentials to connect
    $Cred= Get-Credential
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    #Get the Calendar list
    $CalendarList = $Ctx.web.lists.GetByTitle($CalendarName)

    #Add Calendar Item
    $ListCreationInfo = New-object Microsoft.SharePoint.Client.ListItemCreationInformation
    $ListItem = $CalendarList.AddItem($ListCreationInfo)
    $ListItem.ParseAndSetFieldValue("Title", "Townhall Meeting")
    $ListItem.ParseAndSetFieldValue("Description", "Global Townhall Meetings - Yearly schedule")
    $ListItem.ParseAndSetFieldValue("Location", "Ballroom")
    $ListItem.ParseAndSetFieldValue("EventDate", "01/01/2019 09:00 AM")
    $ListItem.ParseAndSetFieldValue("EndDate", "01/01/2019 06:00 PM")
    Write-host "Calendar Event Added Successfully!" -f Green
Catch {
    write-host -f Red "Error Adding Calendar Item!" $_.Exception.Message

To Set “All Day Event”, set flag “fAllDayEvent” = $true;

PnP PowerShell to Add Calendar Event in SharePoint Online

$SiteURL = ""
$CalendarName = "Team Calendar"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Add Event to Calendar
Add-PnPListItem -List $CalendarName -Values @{"Title" = "Team Meeting"; "Description"= "Monthly Team Meeting"; "Location"= "Ballroom"; "EventDate" = [datetime]"01/01/2019 8AM"; "EndDate"=[datetime]"01/01/2019 6PM";}

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “SharePoint Online: Add Calendar Item using PowerShell

  • August 26, 2021 at 6:59 PM


    I am trying to retrieve all meetings from the calendar and it shows me the wrong time (2 hours off) while web version shows the right time. Any ideas?


    • September 8, 2021 at 10:06 PM

      That is because, SharePoint stores Date-Time values in UTC format, and it applies the site’s timezone on top of it to adjust and display when you view it in the browser.


Leave a Reply