Using PowerShell with RESTful API's - BirdDogHR API Module Posted To Matt Blogs IT
New Post has been published on http://mattblogsit.com/microsoft/windows/powershell/using-powershell-with-restful-apis-birddoghr-api-module
Using PowerShell with RESTful API's - BirdDogHR API Module
In the last few months at work we have been putting a concentrated effort on integrating different cloud hosted systems with our on-premise systems. This usually means using some kind of ETL Tool to interact with an API and either use an API with the on-premise application or dumping directly into a Database.
When we decided to start automating some of our Onboarding Processes the hurdle came up that the ETL Tool isn’t going to trigger Account Creation and other IT related actions. My logical thought was I can interact with an API using PowerShell! I had done this a little bit in the past but nothing significant – so I had a bit of learning to do!
After jumping into this I decided it was appropriate to build a PowerShell Module for interacting with the API, shortly after starting work on the module I decided this needed to be open sourced. Initial building of this API was done while at work; however I have re-written the entire thing in my free time and cleaned up quite a bit of the way I was handling interacting with this API.
Inside of the PowerShell Module you will find a collection of 7 functions. The most critical one is the Get-BirdDogAccessToken. To invoke this function you will need to provide an APIKey, UserName and Password that has API Access that your BirdDogHR Account Representative can provide you. As an Administrator inside of BirdDog you will not be able to create your own API Access. Take a look at a snippet of the module below.
function Get-BirdDogAccessToken <# .SYNOPSIS Get an AccessToken - required for all other API Interactions. .EXAMPLE PS C:\> Get-BirdDogAccessToken -ApiKey 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE' -Credential (Get-Credential) By specifying your ApiKey, UserName and Password provided by BirdDog Account Rep you can get an AccessToken to interact with other API Functions .OUTPUTS Access Token String used with other API Functions #> [CmdletBinding()] param ( [parameter(Mandatory=$true)] [string]$ApiKey, [parameter(Mandatory=$true)] [PSCredential]$Credential, [string]$Version = 'v2', [string]$ApiUri = 'https://api.birddoghr.com' ) begin $UserName = $Credential.UserName $Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) process $uri = "$ApiUri/$Version/accesstoken" $body = @ apiKey = $ApiKey; userName = $UserName; password = $Password [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $json = $body end return $token.token
You can find the v1.0 release of the BirdDogHR API PowerShell Module on my GitHub account by Clicking Here.









