Functions/Export-DatabricksJobsList.ps1

<#
.SYNOPSIS
Exports DataBricks Jobs and Saves as json.
 
.DESCRIPTION
Exports Databricks Jobs List and saves as json.
 
.PARAMETER BearerToken
Your Databricks Bearer token to authenticate to your workspace (see User Settings in Datatbricks WebUI)
 
.PARAMETER Region
Azure Region - must match the URL of your Databricks workspace, example northeurope
 
.PARAMETER LocalOutputPath
Local directroy to save json files.
 
.EXAMPLE
 
.NOTES
Author: Sabin IO
 
#>
 
Function Export-DatabricksJobsList {  
    [cmdletbinding()]
    Param(
        [parameter(Mandatory = $false)][string]$BearerToken,    
        [parameter(Mandatory = $false)][string]$Region,
        [parameter(Mandatory = $true)][string]$LocalOutputPath
    )

    $jobsList = Get-DatabricksJobs -BearerToken $BearerToken -Region $Region
    $jobsListAsJson = $jobsList | ConvertTo-Json -Depth 100
    $jobsListFileName = -join ( 'jobs_list', '.json')

    $LocalExportPath = Join-Path $LocalOutputPath $jobsListFileName
    Write-Verbose "Exporting job to $LocalExportPath"
    New-Item -Force -Path $LocalExportPath -Value $jobsListAsJson -Type file | Out-Null 
}