Functions/Get-DatabricksClusterSingletonByName.ps1

<#
.SYNOPSIS
Get a Single Databricks Cluster
 
.DESCRIPTION
Get a Single Databricks Cluster
 
.PARAMETER ClusterName
The name of the cluster to return.
 
.EXAMPLE
PS C:\> Get-DatabricksClusterSingletonByName -ClusterName 'cluster name'
 
Returns a Single cluster
 
.NOTES
Author: Sabin IO
 
#>


Function Get-DatabricksClusterSingletonByName { 
    [cmdletbinding()]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'ClusterName')]
    param (
 

        [parameter(Mandatory = $true)]
        [string]$ClusterName

        ) 

   

    Try {
        $Cluster = (Get-DatabricksClusters | Where-Object { $_.cluster_name -eq $ClusterName })
   
    }
    Catch {
        Write-Error "StatusCode:" $_.Exception.Response.StatusCode.value__ 
        Write-Error "StatusDescription:" $_.Exception.Response.StatusDescription
        Write-Error $_.ErrorDetails.Message
    }

    return $Cluster
}