I was running the script after modifying a few things to reprovision search and the web app had a different name by then but the same url. The script will try (and fail) to create the web app with the same url.
This is the fix:
In AutoSPInstallerFunctions.ps1
in Function CreateWebApp
Change line:
$getSPWebApplication = Get-SPWebApplication | Where-Object {$_.DisplayName -eq $webAppName }
To this:
$getSPWebApplication = Get-SPWebApplication | Where-Object {$_.DisplayName -eq $webAppName __-or $_.Url -eq $url__}
This is the fix:
In AutoSPInstallerFunctions.ps1
in Function CreateWebApp
Change line:
$getSPWebApplication = Get-SPWebApplication | Where-Object {$_.DisplayName -eq $webAppName }
To this:
$getSPWebApplication = Get-SPWebApplication | Where-Object {$_.DisplayName -eq $webAppName __-or $_.Url -eq $url__}