Line 2637 of AutoSPInstallerfunctions.ps1
Line text:
```
Write-Host -ForegroundColor White " - Creating Site Collection `"$siteURL`"..."
$site = New-SPSite -Url $siteURL -OwnerAlias $ownerAlias -SecondaryOwner $env:USERDOMAIN\$env:USERNAME -ContentDatabase $siteDatabase -Description $siteCollectionName -Name $siteCollectionName -Language $LCID @templateSwitch @hostHeaderWebAppSwitch -ErrorAction Stop
```
Should check if site already exists, otherwise the script halts and fails to configure the remaining actions.
the following should successfully check for existing site (replace the above two lines)
```
$siteExists = Get-SPSite $siteURL -ErrorAction SilentlyContinue
if (!$siteExists)
{
Write-Host -ForegroundColor White " - Creating Site Collection `"$siteURL`"..."
$site = New-SPSite -Url $siteURL -OwnerAlias $ownerAlias -SecondaryOwner $env:USERDOMAIN\$env:USERNAME -ContentDatabase $siteDatabase -Description $siteCollectionName -Name $siteCollectionName -Language $LCID @templateSwitch @hostHeaderWebAppSwitch -ErrorAction Stop
} else {
Write-Host -ForegroundColor White " - Site Collection already exists at `"$siteURL`"..."
$site = $siteExists
}
```
Attached is the updated script.
Comments: ** Comment from web user: brianlala **
Line text:
```
Write-Host -ForegroundColor White " - Creating Site Collection `"$siteURL`"..."
$site = New-SPSite -Url $siteURL -OwnerAlias $ownerAlias -SecondaryOwner $env:USERDOMAIN\$env:USERNAME -ContentDatabase $siteDatabase -Description $siteCollectionName -Name $siteCollectionName -Language $LCID @templateSwitch @hostHeaderWebAppSwitch -ErrorAction Stop
```
Should check if site already exists, otherwise the script halts and fails to configure the remaining actions.
the following should successfully check for existing site (replace the above two lines)
```
$siteExists = Get-SPSite $siteURL -ErrorAction SilentlyContinue
if (!$siteExists)
{
Write-Host -ForegroundColor White " - Creating Site Collection `"$siteURL`"..."
$site = New-SPSite -Url $siteURL -OwnerAlias $ownerAlias -SecondaryOwner $env:USERDOMAIN\$env:USERNAME -ContentDatabase $siteDatabase -Description $siteCollectionName -Name $siteCollectionName -Language $LCID @templateSwitch @hostHeaderWebAppSwitch -ErrorAction Stop
} else {
Write-Host -ForegroundColor White " - Site Collection already exists at `"$siteURL`"..."
$site = $siteExists
}
```
Attached is the updated script.
Comments: ** Comment from web user: brianlala **
What version of the script are you looking at? We already check for the pre-existence of the site collection in this line:
```
$getSPSiteCollection = Get-SPSite -Limit ALL | Where-Object {$_.Url -eq $siteURL}
```
Then before attempting to create the site we do:
```
Write-Host -ForegroundColor White " - Checking for Site Collection `"$siteURL`"..."
If (($getSPSiteCollection -eq $null) -and ($siteURL -ne $null))
...
```
Brian