How to pipe GraphQL Data to CSV in PowerShell



Use standard PowerShell cmdlets to access GraphQL tables.

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

Creating a Connection to Your GraphQL Data

You must specify the URL of the GraphQL service. The driver supports two types of authentication:

  • Basic: Set AuthScheme to Basic. You must specify the User and Password of the GraphQL service.
  • OAuth 1.0 & 2.0: Take a look at the OAuth section in the Help documentation for detailed instructions.

$conn = Connect-GraphQL  -AuthScheme "$AuthScheme" -User "$User" -Password "$Password" -URL "$URL"

Selecting Data

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

Select-GraphQL -Connection $conn -Table Users | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myUsersData.csv -NoTypeInformation

You will notice that we piped the results from Select-GraphQL 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.

Ready to get started?

Download a free trial of the GraphQL Cmdlets to get started:

 Download Now

Learn more:

GraphQL Icon GraphQL Data Cmdlets

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