function Get-AlkamiServiceFabricServerCertificateName { <# .SYNOPSIS Returns the common name of the server certificate for the Service Fabric cluster running at $Hostname .PARAMETER hostname A single server hostname from the target Service Fabric cluster. #> [CmdletBinding()] Param( [Parameter(Mandatory = $false)] [string]$Hostname = "localhost" ) $loglead = (Get-LogLeadName); Write-Verbose "$loglead Looking up the Service Fabric server certificate from $hostname."; $clusterManifestLocation = "C:\ProgramData\SF\clusterManifest.xml"; $clusterManifestLocation = Get-UncPath -filePath $clusterManifestLocation -ComputerName $hostname; if(!(Test-Path $clusterManifestLocation)) { Write-Error "$loglead : Could not find Cluster Manifest config file at '$clusterManifestLocation'. Is this server running Service Fabric?"; return; } # Read the certificate common name to connect to the cluster with. $namespace = @{ x = "http://schemas.microsoft.com/2011/01/fabric" }; $serverCertNode = (Select-Xml -Path $clusterManifestLocation -XPath "//x:ServerCertificate" -Namespace $namespace) | Select-Object -ExpandProperty Node -First 1; if(!([string]::IsNullOrWhiteSpace($serverCertNode.X509FindValue))) { return $serverCertNode.X509FindValue; } else { Write-Warning "$loglead Could not locate a certificate name in the cluster manifest."; return $null; } }