function Test-KnownWCFServicesResolvable { <# .SYNOPSIS Test that a set of WCF services are resolvable .PARAMETER Services This should be an array of one or more services with a property set minimum of: * Name * WebAppName * Endpoint The Name is assumed to be the value used as the hostname for purposes of service resolution for a given WebAppName. .PARAMETER KnownSkipWebApps List of apps that we know we want to skip testing for. Principally useful for ExceptionService, SymConnectMultiplexer, etc #> [CmdletBinding()] [OutputType([void])] param ( [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [object[]]$Services = (Get-KnownWCFServices), [Parameter(Mandatory = $false)] [string[]]$KnownSkipWebApps = (Get-KnownSkipWebAppNames) ) $logLead = Get-LogLeadName $failed = $false $failedCount = 0 # Skip checking the ones that we know we don't need to check foreach ($service in $Services.Where({$_.WebAppName -notin $KnownSkipWebApps})) { $hostnameResolution = Resolve-DNSName -Name $service.Name -ErrorAction SilentlyContinue if ($null -eq $hostnameResolution) { # Don't stop for the first one, log 'em all Write-Error "$logLead : Could not resolve hostname for $($service.Name) used by the WCF service $($service.WebAppName)" -ErrorAction Continue # Ensure we hit the ugly red text but don't stop even if EAP is stop $failed = $true $failedCount += 1 } } if ($failed) { if (($Services.Count -gt 1) -and ($failedCount -eq $Services.Count)) { Write-Warning "$logLead : All of the services appear to have failed, is the hosts file corrupt?" } # Downstream tasks expect us to throw so they will not continue # Ex: Install_Packages -> Install-Server throw "Could not successfully resolve hostnames on $($env:ComputerName)" } Write-Host "$logLead : All services successfully tested for hostname resolution $($Services.WebAppName -join ',')" }