我的 SharePoint 2013 服务器场出现问题。我有一个脚本可以在我的场中创建 Web 应用程序,但是当我这样做时,我无法在该 Web 应用程序中创建发布网站集。(最初发布在这里:https ://sharepoint.stackexchange.com/questions/64308/fails-to-create-publishing-site-collection-in-scripted-web-application
因此,环境设置如下:
- 我们正在为应用程序使用主机头。
- 我们在注册表中设置了 BackConnectionHostNames。
- 现在我们使用 Farm 管理员帐户来运行应用程序池。
- 我们有 mysites 设置并且显然工作。
- 没有设置搜索。
- 我们有一个内容类型中心设置并且显然可以工作。
所以,症状在我看来是这样的:
当我从脚本创建基于主机标头的新 Web 应用程序时,我无法在它中创建发布网站集。当我通过 GUI 创建发布网站集时,它会说“正在处理它”一段时间,然后在仍然旋转“正在处理它”时向我显示一个错误。在事件日志中有这样的阅读:
Event log message was: 'The site template was not provisioned successfully. Delete this site collection in Central Administration, and then create a new site collection.'. Exception was: 'Microsoft.SharePoint.SPException: Provisioning did not succeed. Details: Failed to initialize some site properties for Web at Url: '' OriginalException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
如果我从 Central Admin GUI 创建了 Web 应用程序,我可以在其中成功地创建一个发布门户。
如果我使用我的脚本创建了 Web 应用程序,我可以成功地创建一个团队网站。
下面是我的脚本,任何人都可以看到这显然有问题吗?我是否忘记了 CA GUI 处理的某些内容?
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
Function CreateWebApplication($WebApplicationURL, $HttpPort, $WebApplicationName,
$ContentDatabase, $ApplicationPoolDisplayName,
$ApplicationPoolIdentity, $ApplicationPoolPassword,
$PortalSuperReader, $PortalSuperUser) {
Write-Progress -Activity "Creating Web Application" -Status "Creating Web Application $WebapplicationURL"
if($WebApplicationURL.StartsWith("http://"))
{
$HostHeader = $WebApplicationURL.Substring(7)
$HTTPPort = "80"
}
elseif($WebApplicationURL.StartsWith("https://"))
{
$HostHeader = $WebApplicationURL.Substring(8)
$HTTPPort = "443"
}
$AppPoolManagedAccount = Get-SPManagedAccount $ApplicationPoolIdentity
$AuthenticationProvider = New-SPAuthenticationProvider –UseWindowsIntegratedAuthentication
#Create a new web application using the existing parameters, assign it to the WebApp variable such that object cache user accounts can be configured
$WebApp = New-SPWebApplication -ApplicationPool $ApplicationPoolDisplayName -ApplicationPoolAccount $AppPoolManagedAccount.Username -AuthenticationProvider $AuthenticationProvider -Name $WebApplicationName -url $WebApplicationURL -port $HTTPPort -DatabaseName $ContentDatabase -HostHeader $HostHeader
Write-Progress -Activity "Creating Web Application" -Status "Configuring Object Cache Accounts"
#Assign Object Cache Accounts
$WebApp.Properties["portalsuperuseraccount"] = $PortalSuperUser
$WebApp.Properties["portalsuperreaderaccount"] = $PortalSuperReader
Write-Progress -Activity "Creating Web Application" -Status "Creating Object Cache User Policies for Web Application"
#Create a New Policy for the Super User
$SuperUserPolicy = $WebApp.Policies.Add($PortalSuperUser, "Portal Super User Account")
#Assign Full Control To the Super User
$SuperUserPolicy.PolicyRoleBindings.Add(
$WebApp.PolicyRoles.GetSpecialRole(
[Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl))
#Create a New Policy for the Super Reader
$SuperReaderPolicy = $WebApp.Policies.Add($PortalSuperReader, "Portal Super Reader Account")
#ASsign Full Read to the Super Reader
$SuperReaderPolicy.PolicyRoleBindings.Add(
$WebApp.PolicyRoles.GetSpecialRole(
[Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead))
Write-Progress -Activity "Creating Web Application" -Status "Updating Web Application Properties"
#Commit changes to the web application
$WebApp.update()
}
CreateWebApplication "http://add.ress.lan" 80 "Intranet 3"
"sp_intranet3_content" "Intranet3 Pool" "sp_farm" "P4sswd!"
"sp_superreader" "sp_superuser"