Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate Greenhouse Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Greenhouse data from PowerShell? This article demonstrates how to utilize the Greenhouse Cmdlets for tasks like connecting to Greenhouse data, automating operations, downloading data, and more.
The CData Cmdlets for Greenhouse are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Greenhouse.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Greenhouse, but also an SQL interface; this tutorial shows how to use both to retrieve Greenhouse data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Greenhouse. To access Greenhouse data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Greenhouse.
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.
PowerShell
-
Install the module:
Install-Module GreenhouseCmdlets
-
Connect:
$greenhouse = Connect-Greenhouse -APIKey "$APIKey"
-
Search for and retrieve data:
$status = "Active" $applications = Select-Greenhouse -Connection $greenhouse -Table "Applications" -Where "Status = `'$Status`'" $applications
You can also use the Invoke-Greenhouse cmdlet to execute SQL commands:
$applications = Invoke-Greenhouse -Connection $greenhouse -Query 'SELECT * FROM Applications WHERE Status = @Status' -Params @{'@Status'='Active'}
ADO.NET
-
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 }