How to pipe ServiceNow Data to CSV in PowerShell



Use standard PowerShell cmdlets to access ServiceNow tables.

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

About ServiceNow Data Integration

CData simplifies access and integration of live ServiceNow data. Our customers leverage CData connectivity to:

  • Get optimized performance since CData uses the REST API for data and the SOAP API for schema.
  • Read, write, update, and delete ServiceNow objects like Schedules, Timelines, Questions, Syslogs and more.
  • Use SQL stored procedures for actions like adding items to a cart, submitting orders, and downloading attachments.
  • Securely authenticate with ServiceNow, including basic (username and password), OKTA, ADFS, OneLogin, and PingFederate authentication schemes.

Many users access live ServiceNow data from preferred analytics tools like Tableau, Power BI, and Excel, and use CData solutions to integrate ServiceNow data with their database or data warehouse.


Getting Started


Creating a Connection to Your ServiceNow Data

ServiceNow uses the OAuth 2.0 authentication standard. To authenticate using OAuth, you will need to register an OAuth app with ServiceNow to obtain the OAuthClientId and OAuthClientSecret connection properties. In addition to the OAuth values, you will need to specify the Instance, Username, and Password connection properties.

See the "Getting Started" chapter in the help documentation for a guide on connecting to ServiceNow.

$conn = Connect-ServiceNow  -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -Username "$Username" -Password "$Password" -URL "$URL"

Selecting Data

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

Select-ServiceNow -Connection $conn -Table incident | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myincidentData.csv -NoTypeInformation

You will notice that we piped the results from Select-ServiceNow 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 ServiceNow Cmdlets to get started:

 Download Now

Learn more:

ServiceNow Icon ServiceNow Cmdlets

An easy-to-use set of PowerShell Cmdlets offering real-time access to ServiceNow data. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.