From f6666ace4bf1f94cf4da656152db54a308371c20 Mon Sep 17 00:00:00 2001 From: lknr Date: Wed, 14 Feb 2018 17:36:06 +0100 Subject: [PATCH 1/2] fixes #17 --- AutoSPInstallerFunctions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AutoSPInstallerFunctions.ps1 b/AutoSPInstallerFunctions.ps1 index 49e7bf9..df8f323 100644 --- a/AutoSPInstallerFunctions.ps1 +++ b/AutoSPInstallerFunctions.ps1 @@ -7703,7 +7703,7 @@ Function Stop-DefaultWebsite () # Added to avoid conflicts with web apps that do not use a host header # Thanks to Paul Stork per http://autospinstaller.codeplex.com/workitem/19318 for confirming the Stop-Website cmdlet ImportWebAdministration - $defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.ID -eq 1 -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"} # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs) + $defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"} # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs) Write-Host -ForegroundColor White " - Checking $($defaultWebsite.Name)..." -NoNewline if ($defaultWebsite.State -ne "Stopped") { From 76b0beea177155a4bed85e907e43b80b36ced7fd Mon Sep 17 00:00:00 2001 From: lknr Date: Sat, 24 Feb 2018 14:39:32 +0100 Subject: [PATCH 2/2] [+] Get-DefaultWebsite --- AutoSPInstallerFunctions.ps1 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/AutoSPInstallerFunctions.ps1 b/AutoSPInstallerFunctions.ps1 index df8f323..162746d 100644 --- a/AutoSPInstallerFunctions.ps1 +++ b/AutoSPInstallerFunctions.ps1 @@ -7698,12 +7698,29 @@ Function PinToTaskbar([string]$application) #endregion #region Stop Default Web Site +function Get-DefaultWebsite +{ + [CmdletBinding()] + Param() + + $websites = Get-Website + foreach($ws in $websites) { + if ($ws.id -eq 1 -or $ws.physicalPath -eq "%SystemDrive%\inetpub\wwwroot") { # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs) + $conflictingBinding = $ws.bindings.Collection | ? {$_.protocol -eq 'http' -and $_.bindingInformation -match '\*:80:*'} + if ($conflictingBinding) { return $ws } + Write-Verbose("Found IIS WebSite with either id=1 or physicalPath='%SystemDrive%\inetpub\wwwroot', but it doesn't seem to be default (no '*:80:' http binding)") + } + } + return $null +} + Function Stop-DefaultWebsite () { # Added to avoid conflicts with web apps that do not use a host header # Thanks to Paul Stork per http://autospinstaller.codeplex.com/workitem/19318 for confirming the Stop-Website cmdlet ImportWebAdministration - $defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"} # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs) + $defaultWebsite = Get-DefaultWebsite + if (! $defaultWebsite) { return } Write-Host -ForegroundColor White " - Checking $($defaultWebsite.Name)..." -NoNewline if ($defaultWebsite.State -ne "Stopped") {