运行新spsite时NullReferenceException
-
22-10-2019 - |
题
我正在我的SharePoint服务器上运行以下PowerShell脚本,以创建一个新的主机网站集合和租户管理站点:
Add-PSSnapin microsoft.sharepoint.powershell -ea SilentlyContinue
$featurePackID = "23b570e2-61f8-40ca-8e4d-7625ac7a4d37"
$webApplicationURL = "https://myserver"
$url = "https://test.mysharepoint.com"
$owneralias = "TEST\SP_App01"
$contentDatabase = "WSS_Content_WebApp01"
$template = "STS#0"
$sub = New-SPSiteSubscription
if(!$url.StartsWith("https://")){ $url = "https://$url"; }
if(!$url.StartsWith($webApplicationURL))
{
$hostheader = 'y'
}
#Set Feature Pack
if ($featurePackID -ne "")
{
$FeaturePack = Get-SPSiteSubscriptionFeaturePack $featurePackID
}
if($FeaturePack -ne "" -and $FeaturePack -ne $null){
Set-SPSiteSubscriptionConfig $sub -FeaturePack $FeaturePack
}
if($hostheader -ieq 'y' -or $hostheader -ieq 'yes'){
#Pre-Reqs
if( (Get-SPManagedPath -HostHeader "admin" -ea SilentlyContinue) -eq $null){$void = New-SPManagedPath "admin" -hostheader -explicit}
$wa = Get-SPWebApplication $webApplicationURL
New-SPSite $url -owneralias $owneralias -sitesubscription $sub -hostheaderwebapplication $wa -template $template -contentdatabase $contentdatabase #| set-spsite -maxsize 5000000 -warningsize 4000000
New-SPSite "$url/admin" -owneralias $owneralias -sitesubscription $sub -template "TENANTADMIN#0" -Administrationsitetype "TenantAdministration" -hostheaderwebapplication $wa -contentdatabase $contentdatabase #| set-spsite -maxsize 5000000 -warningsize 4000000
}
else{
New-SPSite $url -owneralias $owneralias -sitesubscription $sub -template "STS#0" | set-spsite -maxsize 5000000 -warningsize 4000000
New-SPSite "$url/admin" -owneralias $owneralias -sitesubscription $sub -template "TENANTADMIN#0" -Administrationsitetype "TenantAdministration" | set-spsite -maxsize 5000000 -warningsize 400000
}
但是我遇到以下错误:
new-spsite:对象引用未设置为对象的实例。 + new -spsite <<<< $ url -url -outeralias $ owneralias -sitesubscription $ sub -hostheaderwebapplication $ wa -template $ template $ template -contentdata base $ contentDatabase#| set-spsite -maxsize 5000000 -warningsize 4000000 + CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletNewSite:SPCmdletNewSite) [New-SPSite], NullReferenceException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite
有什么想法吗?
解决方案
事实证明,这是一个权限错误。我重新运行了脚本,而没有指定模板,但将我的帐户设置为Osseralias。然后,我运行了此脚本来设置模板:
Get-SPSite https://test.mysharepoint.com | Set-SPSite -Template "TenantAdmin#0" -Administrationsitetype "TenantAdministration"
嘿,普雷斯托 - 都在工作。然后我进去,快乐地改变了主人。