I am using Remote PowerShell Session to create SharePoint Site. The client computer is not part of AD forest.
I have used the following PowerShell commands to enter into the remote session.
$cred = Get-Credential
$session = New-PSSession -ComputerName "SPServerName" -Credential $cred
Enter-PSSession $session
Add-PSSnapin Microsoft.SharePoint.PowerShell
and following commands to create SharePoint Site
$w = Get-SPWebApplication http://SPServerName:8000/
New-SPSite http://sp.test.com -OwnerAlias "ad\spuser" -HostHeaderWebApplication $w -Name "Test Site"
And I am getting the following error
New-SPSite : User cannot be found. At line:1 char:1 + New-SPSite http://sp.test.com -OwnerAlias "ad\spuser" -HostH ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletNewSite:SPCmdletNewSite) [New-SPSite], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite
However, I am able to create SharePoint Site successfully from within SharePoint server using same PowerShell commands.