Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate BambooHR Integration Tasks from PowerShell
Are you in search of a quick and easy way to access BambooHR data from PowerShell? This article demonstrates how to utilize the BambooHR Cmdlets for tasks like connecting to BambooHR data, automating operations, downloading data, and more.
The CData API Driver for ADO.NET 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 BambooHR.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for BambooHR; this tutorial shows how to use the Provider to retrieve BambooHR data.
Once you have acquired the necessary connection properties, accessing BambooHR data in PowerShell can be enabled in three steps.
Start by setting the Profile connection property to the location of the BambooHR Profile on disk (e.g. C:\profiles\bamboohr.apip). Next, set the ProfileSettings connection property to the connection string for BambooHR (see below).
BambooHR API Profile Settings
In order to authenticate to BambooHR, you'll need to provide your API Key. To generate an API key, log in and click your name in the upper right-hand corner of any page to get to the user context menu. If you have sufficient permissions, there will be an "API Keys" option in that menu to go to the page, where you can create a new API Key. Additionally, you will need to set the Domain, found in the domain name of your BambooHR account. For example if your BambooHR account is acmeinc.bamboohr.com, then the Domain should be 'acmeinc'. Set both the API Key and Domain in the ProfileSettings property to connect.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData API Driver for ADO.NET\lib\System.Data.CData.API.dll")
-
Connect to BambooHR:
$conn= New-Object System.Data.CData.API.APIConnection("Profile=C:\profiles\BambooHR.apip;ProfileSettings='Domain=acmeinc;APIKey=your_api_key';") $conn.Open()
-
Instantiate the APIDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, DisplayName from Employees" $da= New-Object System.Data.CData.API.APIDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.displayname }