Pipe Google Cloud Storage Data to CSV in PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Google Cloud Storage Data Cmdlets

An easy-to-use set of PowerShell Cmdlets offering real-time access to Google Cloud Storage. The Cmdlets allow users to access live data - just like working with SQL server.



Use standard PowerShell cmdlets to access Google Cloud Storage tables.

The CData Cmdlets Module for Google Cloud Storage is a standard PowerShell module offering straightforward integration with Google Cloud Storage. Below, you will find examples of using our GoogleCloudStorage Cmdlets with native PowerShell cmdlets.

Creating a Connection to Your Google Cloud Storage Data

Authenticate with a User Account

You can connect without setting any connection properties for your user credentials. After setting InitiateOAuth to GETANDREFRESH, you are ready to connect.

When you connect, the Google Cloud Storage OAuth endpoint opens in your default browser. Log in and grant permissions, then the OAuth process completes

Authenticate with a Service Account

Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to delegate enterprise-wide access scopes.

You need to create an OAuth application in this flow. See the Help documentation for more information. After setting the following connection properties, you are ready to connect:

  • InitiateOAuth: Set this to GETANDREFRESH.
  • OAuthJWTCertType: Set this to "PFXFILE".
  • OAuthJWTCert: Set this to the path to the .p12 file you generated.
  • OAuthJWTCertPassword: Set this to the password of the .p12 file.
  • OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
  • OAuthJWTIssuer: In the service accounts section, click Manage Service Accounts and set this field to the email address displayed in the service account Id field.
  • OAuthJWTSubject: Set this to your enterprise Id if your subject type is set to "enterprise" or your app user Id if your subject type is set to "user".
  • ProjectId: Set this to the Id of the project you want to connect to.

The OAuth flow for a service account then completes.

$conn = Connect-GoogleCloudStorage  -ProjectId "$ProjectId"

Selecting Data

Follow the steps below to retrieve data from the Buckets table and pipe the result into to a CSV file:

Select-GoogleCloudStorage -Connection $conn -Table Buckets | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myBucketsData.csv -NoTypeInformation

You will notice that we piped the results from Select-GoogleCloudStorage into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.

The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.