The SP 2013 App model requires the use of Host Named Site Collection which in turn means the web application that will host the App domains must not have a host header. Line 1789 in AutoSPInstallerFunctions.ps1 forces the HostHeader option of New-SPWebApplication. I put an if block around it to check if the $webApp.name was equal to my portal name and if so call New-SPWebApplication without the -HostHeader option which worked for me.
As I am writing this, I'm thinking that another way to determined whether or not to call New-SPWebApplication with the -HostHeader option could have been to compare the $webApp.url to $xmlinput.Configuration.ServiceApps.AppManagementService.AppDomain -or- add a new configuration item under WebApplication named hostHeader that accepts either a true/false or an actual hostHeader that could be left blank.
Joe
Comments: ** Comment from web user: pstork **
As I am writing this, I'm thinking that another way to determined whether or not to call New-SPWebApplication with the -HostHeader option could have been to compare the $webApp.url to $xmlinput.Configuration.ServiceApps.AppManagementService.AppDomain -or- add a new configuration item under WebApplication named hostHeader that accepts either a true/false or an actual hostHeader that could be left blank.
Joe
Comments: ** Comment from web user: pstork **
Good Catch Brian. You can stop the existing default web site by including
Stop-WebSite -Name "Default Web Site"
before creating the new web app in the branch without the Host Header entry. Stopping it if its already stopped doesn't throw an error.