function New-AppTierHostFileEntries { <# .SYNOPSIS Create new app tier host file entries #> [CmdletBinding()] Param() $logLead = (Get-LogLeadName) $hostsContent = Get-HostsFileContent $hostsToAdd = @() # Add hosts entry for everything except the multiplexer # We have to figure out how to programatically find the VIP for SymConnect foreach ($app in $appTierApplications | Where-Object {$_.Name -ne "SymConnectMultiplexer"}) { # First try to resolve by name to see if DNS is handling try { $addresses = Get-IPAddressesForName $app.Name } catch { # No action needed, check is below $addresses = $null } if (!(Test-IsCollectionNullOrEmpty $addresses)) { Write-Output ("$logLead : IP Address for App {0} Resolved" -f $app.Name) continue } $hostsString = "127.0.0.1{0}{1}" # This is a redundant check since we're already checking DNS for the Service Name, but it doesn't hurt if (($hostsContent | Where-Object {$_ -like ($hostsString -f "*", $app.Name)}).Count -gt 0) { Write-Output ("$logLead : HostsEntry for {0} Already Exists" -f $app.Name) continue } $hostsToAdd += ($hostsString -f "`t`t", $app.Name) } if ($hostsToAdd.Count -gt 0) { Add-HostsFileContent $hostsToAdd -Force } else { Write-Output "$logLead : No Host File Updates Required" } } Set-Alias -name Create-AppTierHostFileEntries -value New-AppTierHostFileEntries;