Thursday, July 4, 2013

URL format in New-SPSite

When creating a new site collection using PowerShell:

New-SPSite $siteCollUrl -Name $siteCollName -Template $template -OwnerAlias $siteCollAdmin –Language $siteCollLanguage

you might get an exception:

New-SPSite : The URL '/sites/sitecollname/' is invalid.  It may contain illegal characters, or be too long.

The problem is caused by the trailing slash in the new site collection URL. It should be removed.