Functions/Get-CachedDatabricksClusterId.ps1
Function Get-CachedDatabricksClusterId { param($ClusterName) if ($null -eq $ClusterIdCache) { $global:ClusterIdCache = @{} } if (-not $global:ClusterIdCache.ContainsKey($ClusterName)) { $WorkspaceClusters = Get-DatabricksClusters foreach ($WorkspaceCluster in $WorkspaceClusters) { $WorkspaceClusterName = $WorkspaceCluster.cluster_name $global:ClusterIdCache.$WorkspaceClusterName = $WorkspaceCluster.cluster_id } } if ($null -eq $global:ClusterIdCache.$ClusterName){ Write-Warning "$ClusterName not found on workspace." } return @{Id = $global:ClusterIdCache.$ClusterName}.Id } |