Automate Google Calendar Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Google Calendar data from PowerShell? This article demonstrates how to utilize the Google Calendar Cmdlets for tasks like connecting to Google Calendar data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Google Calendar is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Google Calendar.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Google Calendar; this tutorial shows how to use the Provider to create, retrieve, update, and delete Google Calendar data.

Once you have acquired the necessary connection properties, accessing Google Calendar data in PowerShell can be enabled in three steps.

You can connect to Google APIs on behalf of individual users or on behalf of a domain. Google uses the OAuth authentication standard. See the "Getting Started" section of the help documentation for a guide.

  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Google Calendar\lib\System.Data.CData.GoogleCalendar.dll")
        
  2. Connect to Google Calendar:

     
    $conn= New-Object System.Data.CData.GoogleCalendar.GoogleCalendarConnection("")
    $conn.Open()
    
  3. Instantiate the GoogleCalendarDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT Summary, StartDateTime from VacationCalendar"
    
    $da= New-Object System.Data.CData.GoogleCalendar.GoogleCalendarDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.summary $_.startdatetime
    }
      

Update Google Calendar Data


$cmd =  New-Object System.Data.CData.GoogleCalendar.GoogleCalendarCommand("UPDATE VacationCalendar SET SearchTerms='beach trip' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCalendar.GoogleCalendarParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Google Calendar Data


$cmd =  New-Object System.Data.CData.GoogleCalendar.GoogleCalendarCommand("INSERT INTO VacationCalendar (SearchTerms) VALUES (@mySearchTerms)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCalendar.GoogleCalendarParameter("@mySearchTerms","beach trip")))
$cmd.ExecuteNonQuery()

Delete Google Calendar Data


$cmd =  New-Object System.Data.CData.GoogleCalendar.GoogleCalendarCommand("DELETE FROM VacationCalendar WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCalendar.GoogleCalendarParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Google Calendars Data Provider to get started:

 Download Now

Learn more:

Google Calendars Icon Google Calendars ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Google Calendar data including Calendars, Events, Attendees, and more!