New-SPSite : User cannot be found

I recently had a bit of a head-scratcher with a "User cannot be found" error when using PowerShell to create a site collection in SharePoint Server 2010. My command was quite simple:
New-SPSite -url http://servername/sites/site -owneralias "domain\username" -template "STS#0" -Name "Site Title Here"

I received an error "User cannot be found"

If I removed the "domain\" the command worked every time:

New-SPSite -url http://servername/sites/site -owneralias "username" -template "STS#0" -Name "Site Title Here"

I hope this helps someone else who runs into this issue.

Comments

Troy Brittain said…
What's up Greg, thanks for the tip. Hope you're doing well, see you around - Troy Brittain
At first look, this seems workable:
New-SPSite ... -OwnerAlias "administrator"
In fact, after this line being run, the owner might be a local account (in case a local account has the same name as its domain counterpart):
(Get-SPSite -Identity http://...site...coll..).Owner.UserLogin
Here is shown the local account, right?
At first look, this seems workable:
New-SPSite ... -OwnerAlias "administrator"
In fact, after this line being run, the owner might be a local account (in case a local account has the same name as its domain counterpart):
(Get-SPSite -Identity http://...site...coll..).Owner.UserLogin
Here is shown the local account, right?
Greg Zook said…
Hi Alexander, no this was a domain account.
Anonymous said…
This happened to me in SP2013 Foundation. I created root site fine (portal.contoso.com), with host-header web app equal to servername, as per TechNet guidance. When I attempted to create a host-named site collection called intranet.contoso.com, it failed: user cannot be found. I used the recommendation here and it worked. THANKS!
Unknown said…
I just had the same issue in SP2013 Enterprise.
The solution for me was to make a variable for the Userdomain, and use the variable in front of the username, instead of writing the domainname directly.

This is how my script looks like now. It will read the sitenames from a txt file named sites.txt.
$Userdomain = gc env:UserDomain
$sites = Get-Content .\sites.txt
$owner = "$userdomain\user1"
$secowner = "$userdomain\user2"
$template = "STS#0"
$environment = "http://sharepoint/sites/"
foreach ($site in $sites) {
new-spsite -url $environment$site -owneralias $owner -secondaryowneralias $secowner -template $template -name $site
write-host "$environment$site has been created"
}

Popular posts from this blog

ADMT fails to migrate SID History

Exchange 2010 event errors 2601, 2604, 2501

Robocopy Error 31 A device attached to the system is not functioning