Hello Alex,
I wrote a PowerShell script to pull all the DataLink connectors for our DL instance and save the csv data to your local desktop. Please see below and I would be happy to provide feedback if you have any questions.
You must update the below bolded and underlined code with your DL connector url.
example:
YOURDATALINKURLHERE would be replaced with, dl-YOURCOMPANYName-manager.apptio.com
You must also use an API key from your Front Door user management to pull information using this script. I cannot use simple username/password pairs in my company so the API key was used. More information about API keys can be found here, API keys and Frontdoor: Overview and FAQs (Outdated; click for updated version) . The script will check for encrypted files in your executable path and if no keys are found it will ask you to enter them then encrypt them in your executable path for future API calls.
#############################################################################################################
#Script to use API calls for Apptio FrontDoor applications #
#Script written by Robert Schneider December 15th 2017 currently using Robert Schneider's API Key #
#############################################################################################################
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent #set the current path of the script Get-location |select path
$secretkey = "$PSScriptRoot\secretkey.pwd" #setting path of secretkey file
$publickey = "$PSScriptRoot\publickey.pwd" #setting path of publickey file
if (((Test-Path $secretkey) -eq $false) -or (Test-Path $publickey) -eq $false){ #testing path for public / secret key file
#below is a custom input form for the public/private key pair
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Public/Private Key Entry"
$objForm.Size = New-Object System.Drawing.Size(300,250)
$objForm.StartPosition = "CenterScreen"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,180)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.DialogResult = [System.windows.forms.dialogresult]::OK
$objForm.AcceptButton= $OKButton
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,180)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.DialogResult = [System.windows.forms.dialogresult]::Cancel
$objForm.AcceptButton= $CancelButton
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "PLEASE ENTER PUBLIC KEY:"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,100)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "PLEASE ENTER PRIVATE KEY:"
$objForm.Controls.Add($objLabel)
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Location = New-Object System.Drawing.Size(10,120)
$objTextBox2.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox2)
$objForm.topmost = $true
$result = $objform.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$x= $objTextBox.Text
$y= $objTextBox2.Text
}
if ($result -eq [System.Windows.Forms.DialogResult]::Cancel)
{
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("YOU HAVE CANCELLED YOUR INPUT, PLEASE TRY AGAIN AND ENSURE YOU'RE SELECTING OK.",0,"Error")|Out-Null
exit}
#end of custom input form for the public/private key pair
$x|ConvertTo-SecureString -AsPlainText -Force|convertFrom-SecureString > $publickey #exporting and encrypting public
$y|ConvertTo-SecureString -AsPlainText -Force|convertFrom-SecureString > $secretkey #exporting and encrypting secretkey
}
$secretkeyplain = Get-Content -path $secretkey #pulling encrypted secretkey
$publickeyplain = Get-Content -path $publickey #pulling encrypted publickey
$PlainTextSecret= [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR( (ConvertTo-SecureString $secretkeyplain) )) #unencrypting secretkey
$PlainTextPublic= [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR( (ConvertTo-SecureString $publickeyplain) ))#unencrypting publickey
$string =@{keySecret=$PlainTextSecret;keyAccess=$PlainTextPublic} |convertto-json -compress #creating hash-table to pass public/private key pair to apptio
$header = Invoke-WebRequest -Method Post -Uri 'https://frontdoor.apptio.com/service/apikeylogin' -ContentType "application/json" -Body $string |Select -ExpandProperty headers #retrieving key header for opentoken
$opentoken=@{"apptio-opentoken"=$header."apptio-opentoken"} #must be in a table format for passing credentials must pass in -header parameter in invoke-restmethod (get) and Invoke-WebRequest (curl/post)
#############################################################################################################
#Remaining script are API calls using opentoken from authentication above must pass $opentoken in -header #
#############################################################################################################
$dlagentlist = Invoke-RestMethod -Method Get -Uri 'https://PUTYOURDATALINKURLHERE/api/v1/resource/agent?include=name' -Headers $opentoken | Select-Object result -ExpandProperty result |select url #retrieves URL agent key for pulling connectors
foreach ($agent in $dlagentlist){ #foreach loop if url has multiple agents
$url = $agent.url #setting URL variable for API call below
Invoke-RestMethod -Method Get -Uri "$url/connector?include=name,type" -Headers $opentoken | Select-Object result -ExpandProperty result |select connectorId,url,name,type | Export-Csv C:\Users\$env:USER\Desktop\Connectors_List.csv -Append -NoTypeInformation} #pulling all connector information available via API and saving to your desktop