controls/secretmanager-grid.ps1

function New-UDSecretManagerGrid
{
    New-UDGrid -Id "secretmanager-Grid" -Title "Secret Managers" -Headers @("Id", "Name", "Variable","GetSecretScript","RequiredPowerShellVersion") -Properties @("Id", "Name", "Variable","GetSecretScript","RequiredPowerShellVersion") -Endpoint {

        $VariablesWithSecrets = Get-UAVariable | Where-Object {$_.SecretManager}
        
        Get-UASecretManager  | ForEach-Object {
            $RelatedVariable = ($VariablesWithSecrets | Where-Object{$_.SecretManager.Id -eq $_.Id})
            
            if($null -eq $RelatedVariable)
            {
                $RelatedVariableCell = "N/A"
            }
            else
            {
                $RelatedVariableCell = ($RelatedVariable.Name +  " : " + $RelatedVariable.Id)
            }
            
            [PSCustomObject]@{
                Id = $_.Id
                Name = $_.Name
                Variable = $RelatedVariableCell
                GetSecretScript = $_.GetSecretScript
                RequiredPowerShellVersion = $_.RequiredPowerShellVersion
            }
        } | Out-UDGridData
    } -AutoRefresh
}