Click here to Skip to main content
13,088,711 members (55,521 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 18 Apr 2012

Use PowerShell to List Google Docs

, 18 Apr 2012
Rate this:
Please Sign up or sign in to vote.
The Google Data Provider provides an easy-to-use ADO.NET interface that you can take advantage of with your PowerShell Scripts.

Are you looking for a quick and easy way to access your Google Docs from PowerShell? The Google Data Provider provides an easy-to-use ADO.NET interface that you can take advantage of with your PowerShell Scripts. Simply use the included SQL like .NET objects (GoogleConnection, GoogleCommand, GoogleDataAdapter, etc.) in your PowerShell scripts to connect to your Google Apps accounts and synchronize, automate, download, and more!

Using the Google Data Provider in PowerShell to List Google Docs

# Load the Google Data Provider assembly 
[Reflection.Assembly]::LoadFile("C:\Program Files\RSSBus\RSSBus 
        Google Data Provider\lib\System.Data.RSSBus.Google.dll")

# Connect to Google 
$constr = "User=[username];Password=[password]"
$conn= New-Object System.Data.RSSBus.Google.GoogleConnection($constr)

$sql="SELECT Name, AuthorName, Type, Updated, Weblink from Documents"

$da= New-Object System.Data.RSSBus.Google.GoogleDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable

$dt.Rows | foreach {
	Write-Host $_.updated $

Listing is only the first step. With full CRUD support, you can use the Google Data Provider to easily upload and download documents as well. The following bit of PowerShell code downloads one of the documents listed above.

Download a File from Google Docs

$cmd= New-Object System.Data.RSSBus.Google.GoogleCommand("DownloadDocument", $conn)
$cmd.CommandType= [System.Data.CommandType]'StoredProcedure'
$cmd.Parameters.Add( (New-Object System.Data.RSSBus.Google.GoogleParameter("@Type", "TXT")) ) 
$cmd.Parameters.Add( (New-Object System.Data.RSSBus.Google.GoogleParameter("@Name", "myfile")) ) 
( (New-Object System.Data.RSSBus.Google.GoogleParameter("@LocalFile", "d:\myfile.txt")) ) 
$reader = $cmd.ExecuteReader()

Likewise, calling the UploadDocument Stored Procedure allows your scripts to upload documents directly to Google Docs.

As you can see, the Google Data Provider provides a hassle-free way to access the features of Google Apps directly from PowerShell script, and eliminates the headache involved with authentication, security, etc. Happy scripting!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
RSSBus ( provides high-performance, reliable, and fully-extensible products that simplify the process of producing, consuming, and integrating data. The RSSBus products enable a simple yet effective layer of middleware that helps users drive information flow without the added complexity that is common across other integration solutions.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 18 Apr 2012
Article Copyright 2012 by DataIntegration
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid