Public/Remove-DatabricksNotebook.ps1
<#
.SYNOPSIS Removes a Databricks notebook or folder from the workspace .DESCRIPTION Removes a Databricks notebook or folder from the workspace .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 Path Absolute path - wildcards not accepted .PARAMETER Recursive Switch defaults to $False, recurseivly delete everything in folder .EXAMPLE PS C:\> Remove-DatabricksNotebook -BearerToken $BearerToken -Region $Region -Path '/Shared/Bob/Test1' -Recursive .NOTES Author: Simon D'Morias / Data Thirst Ltd #> Function Remove-DatabricksNotebook { [cmdletbinding()] param ( [parameter(Mandatory = $false)][string]$BearerToken, [parameter(Mandatory = $false)][string]$Region, [parameter(Mandatory = $true)][string]$Path, [parameter(Mandatory = $false)][switch]$Recursive ) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Headers = GetHeaders $PSBoundParameters $body = @{} If ($PSBoundParameters.ContainsKey('Recursive')) { $Body['recursive'] = $true } $Body['path'] = $Path Try { $BodyText = $Body | ConvertTo-Json -Depth 10 Invoke-RestMethod -Uri "$global:DatabricksURI/api/2.0/workspace/delete" -Body $BodyText -Method 'POST' -Headers $Headers } Catch { Write-Output "StatusCode:" $_.Exception.Response.StatusCode.value__ Write-Output "StatusDescription:" $_.Exception.Response.StatusDescription Write-Output $_.Exception Write-Error $_.ErrorDetails.Message Return } } |