Automate Greenhouse Integration Tasks from PowerShell
The CData ADO.NET Provider for Greenhouse is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Greenhouse.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Greenhouse; this tutorial shows how to use the Provider to retrieve Greenhouse data.
Once you have acquired the necessary connection properties, accessing Greenhouse data in PowerShell can be enabled in three steps.
You need an API key to connect to Greenhouse. To create an API key, follow the steps below:
- Click the Configure icon in the navigation bar and locate Dev Center on the left.
- Select API Credential Management.
- Click Create New API Key.
- Set "API Type" to Harvest.
- Set "Partner" to custom.
- Optionally, provide a description.
- Proceed to Manage permissions and select the appropriate permissions based on the resources you want to access through the driver.
- Copy the created key and set APIKey to that value.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Greenhouse\lib\System.Data.CData.Greenhouse.dll") -
Connect to Greenhouse:
$conn= New-Object System.Data.CData.Greenhouse.GreenhouseConnection("APIKey=YourAPIKey;") $conn.Open() -
Instantiate the GreenhouseDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, CandidateId from Applications" $da= New-Object System.Data.CData.Greenhouse.GreenhouseDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.candidateid }