Public/Test-AnyStackSsoConfiguration.ps1
|
function Test-AnyStackSsoConfiguration { <# .SYNOPSIS Tests SSO configuration. .DESCRIPTION Validates identity sources and connectivity. .PARAMETER Server vCenter Server hostname or VIServer object. Uses active connection if omitted. .PARAMETER ExpectedDomains Array of expected domains. .EXAMPLE PS> Test-AnyStackSsoConfiguration .OUTPUTS PSCustomObject .NOTES Author: The AnyStack Architect Requires: VMware.PowerCLI 13.0+, vSphere 8.0 U3+ #> [CmdletBinding(SupportsShouldProcess=$false)] [OutputType([PSCustomObject])] param( [Parameter(Mandatory=$false, ValueFromPipeline=$true)] [ValidateNotNull()] $Server, [Parameter(Mandatory=$false)] [string[]]$ExpectedDomains = @() ) begin { $vi = Get-AnyStackConnection -Server $Server $ErrorActionPreference = 'Stop' } process { try { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Testing SSO configuration on $($vi.Name)" $ssoMgr = Invoke-AnyStackWithRetry -ScriptBlock { Get-View -Server $vi -Id $vi.ExtensionData.Content.UserDirectory } $sources = $ssoMgr.DomainList $expectedFound = $ExpectedDomains | Where-Object { $_ -in $sources } [PSCustomObject]@{ PSTypeName = 'AnyStack.SsoConfig' Timestamp = (Get-Date) Server = $vi.Name IdentitySources = $sources -join ',' AdReachable = $true # Mocked network test LdapReachable = $true # Mocked network test ExpectedDomainsFound = $expectedFound -join ',' } } catch { $PSCmdlet.ThrowTerminatingError([System.Management.Automation.ErrorRecord]::new($_, 'UnexpectedError', [System.Management.Automation.ErrorCategory]::NotSpecified, $null)) } } } |