first of all I want to tell you that you are doing a great job !!! :)
i have problem with AddToHOSTS function, i use this script for a farm with two servers, i have provisonning Central Administration on one server with his Hostname in url (https://AppServerName) and when i execute script on the second server function add record "127.0.0.1 AppServerName" in host.
This record cause problem for Search Topology configuration because search service admin component is not on this server.
Could you modify script to don't add Central administration url in local host file if Central Administration is not provionned on local server ?
Thank in adavance,
Florent.
Comments: ** Comment from web user: Florent123 **
Hello,
I specify a web application with option add to host set to True, or in function "CreateWebApplications" this option launch execution of "AddToHOSTS" function without parameters.
# Updated so that we don't add URLs to the local hosts file of a server that's not running the Foundation Web Application service
If ($xmlinput.Configuration.WebApplications.AddURLsToHOSTS -eq $true -and !(($xmlinput.Configuration.Farm.Services.SelectSingleNode("FoundationWebApplication")) -and !(ShouldIProvision $xmlinput.Configuration.Farm.Services.FoundationWebApplication -eq $true)))
{AddToHOSTS}
And if function "AddToHOSTS" is executed without parameters, $Hosts variable equal all alternate urls:
if (!$hosts) # No hosts were passed as arguments, so look at the AAMs in the farm
{
# Get a list of the AAMs and weed out the duplicates
$hosts = Get-SPAlternateURL | ForEach-Object {$_.incomingurl.replace("https://","").replace("http://","")} | where-Object { $_.tostring() -notlike "*:*" } | Select-Object -Unique
}
And in the alternate urls list we can found central admin url, in my case this is the server name that it add to host file.
Regards,
Florent.