Quantcast
Channel: AutoSPInstaller
Viewing all articles
Browse latest Browse all 2279

Created Unassigned: Script halts if site collection exists (v3.96) line 2637 [20917]

$
0
0
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.

Viewing all articles
Browse latest Browse all 2279

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>