How to pipe Workday Data to CSV in PowerShell



Use standard PowerShell cmdlets to access Workday tables.

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

About Workday Data Integration

CData provides the easiest way to access and integrate live data from Workday. Customers use CData connectivity to:

  • Access the tables and datasets you create in Prism Analytics Data Catalog, working with the native Workday data hub without compromising the fidelity of your Workday system.
  • Access Workday Reports-as-a-Service to surface data from departmental datasets not available from Prism and datasets larger than Prism allows.
  • Access base data objects with WQL, REST, or SOAP, getting more granular, detailed access but with the potential need for Workday admins or IT to help craft queries.

Users frequently integrate Workday with analytics tools such as Tableau, Power BI, and Excel, and leverage our tools to replicate Workday data to databases or data warehouses. Access is secured at the user level, based on the authenticated user's identity and role.

For more information on configuring Workday to work with CData, refer to our Knowledge Base articles: Comprehensive Workday Connectivity through Workday WQL and Reports-as-a-Service & Workday + CData: Connection & Integration Best Practices.


Getting Started


Creating a Connection to Your Workday Data

To connect to Workday, users need to find the Tenant and BaseURL and then select their API type.

Obtaining the BaseURL and Tenant

To obtain the BaseURL and Tenant properties, log into Workday and search for "View API Clients." On this screen, you'll find the Workday REST API Endpoint, a URL that includes both the BaseURL and Tenant.

The format of the REST API Endpoint is: https://domain.com/subdirectories/mycompany, where:

  • https://domain.com/subdirectories/ is the BaseURL.
  • mycompany (the portion of the url after the very last slash) is the Tenant.
For example, in the REST API endpoint https://wd3-impl-services1.workday.com/ccx/api/v1/mycompany, the BaseURL is https://wd3-impl-services1.workday.com and the Tenant is mycompany.

Using ConnectionType to Select the API

The value you use for the ConnectionType property determines which Workday API you use. See our Community Article for more information on Workday connectivity options and best practices.

APIConnectionType Value
WQLWQL
Reports as a ServiceReports
RESTREST
SOAPSOAP

Authentication

Your method of authentication depends on which API you are using.

  • WQL, Reports as a Service, REST: Use OAuth authentication.
  • SOAP: Use Basic or OAuth authentication.

See the Help documentation for more information on configuring OAuth with Workday.

$conn = Connect-Workday  -User "$User" -Password "$Password" -Tenant "$Tenant" -BaseURL "$BaseURL" -ConnectionType "$ConnectionType"

Selecting Data

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

Select-Workday -Connection $conn -Table Workers | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myWorkersData.csv -NoTypeInformation

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

Deleting Data

The following line deletes any records that match the criteria:

Select-Workday -Connection $conn -Table Workers -Where "Legal_Name_Last_Name = Morgan" | Remove-Workday

Inserting and Updating Data

The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into Workday, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyWorkersUpdates.csv | %{
  $record = Select-Workday -Connection $Workday -Table Workers -Where ("Id = `'"+$_.Id+"`'")
  if($record){
    Update-Workday -Connection $workday -Table Workers -Columns ("Worker_Reference_WID","Legal_Name_Last_Name") -Values ($_.Worker_Reference_WID, $_.Legal_Name_Last_Name) -Where ("Id = `'"+$_.Id+"`'")
  }else{
    Add-Workday -Connection $workday -Table Workers -Columns ("Worker_Reference_WID","Legal_Name_Last_Name") -Values ($_.Worker_Reference_WID, $_.Legal_Name_Last_Name)
  }
}

As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!

Ready to get started?

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

 Download Now

Learn more:

Workday Icon Workday Data Cmdlets

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