【发布时间】:2013-06-27 14:40:17
【问题描述】:
我正在尝试通过来自构建服务器的远程 powershell 自动执行 sharepoint 2013 部署。一切都按预期执行,除非与 sharepoint dll 中的某些类有关,例如 (Microsoft.SharePoint.Publishing, Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings)
如果我在本地使用相同的凭据运行相同的脚本,它运行良好。
我考虑过以下几点:
- 用户在两台机器上都拥有完全的管理员权限
- 在远程服务器上禁用 UAC
- 在 thig post (http://social.technet.microsoft.com/Forums/sharepoint/en-US/09b60466-5432-48c9-aedd-1af343e957de/user-cannot-be-found-when-using-invokecommand-newspsite-on-sharepoint) 中遵循了所需的 Remote Powershell 步骤
- 我通过注册表默认设置了 powershell 以管理员身份运行 (
New-Item -Path "Registry::HKEY_CLASSES_ROOT\Microsoft.PowershellScript.1\Shell\runas\command" -Force -Name '' -Value '"c:\windows\system32\windowspowershell\v1.0\powershell.exe" -noexit "%1"')
脚本代码:
#Set the radio buttons value
$settings = New-Object Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings (,$rootWeb)
$settings.GlobalNavigation.Source = [Microsoft.SharePoint.Publishing.Navigation.StandardNavigationSource]::PortalProvider
#Set the radio buttons value
$settings.CurrentNavigation.Source = [Microsoft.SharePoint.Publishing.Navigation.StandardNavigationSource]::PortalProvider
write-host "I am here.........................."
$settings.Update()
#Set the Publishing Web
$SPPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($rootWeb)
#Global Navigation Settings
$SPPubWeb.Navigation.InheritGlobal = $false
$SPPubWeb.Navigation.GlobalIncludePages = $false
Remote Powershell 输出如下:
I am here..........................
Exception calling "Update" with "0" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
+ PSComputerName : Contoso-DEVSP
Exception setting "GlobalIncludePages": "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
+ PSComputerName : Contoso-DEVSP
在此先感谢
【问题讨论】:
-
实际上是一个快速更新,似乎它的 Sharepoint 在发布站点时拒绝访问其站点。所以我的发现现在指向我的 Sharepoint 是偏执而不是 dll 信任级别。
-
忘记添加执行发布的用户是共享点农场管理员和站点管理员。当发布在本地发生时,我猜身份验证发生在 sharepoint 上,但是当脚本通过 Remote-Powershell Access denied 运行时抛出异常。
标签: powershell sharepoint-2013 remote-server powershell-remoting