Quantcast
Channel: autospinstaller Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1245

Commented 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.
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


Viewing all articles
Browse latest Browse all 1245

Trending Articles



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