0

我正在尝试通过构建服务器的远程 powershell 自动执行 sharepoint 2013 部署。一切都按预期执行,除非与 sharepoint dll 中的某些类有关,例如 (Microsoft.SharePoint.Publishing, Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings)

如果我在相同的凭据下本地运行相同的脚本,它运行良好。

我考虑了以下内容:

  1. 用户在两台机器上都拥有完全的管理员权限
  2. 在远程服务器上禁用 UAC
  3. 遵循了帖子中所需的远程 Powershell 步骤(http://social.technet.microsoft.com/Forums/sharepoint/en-US/09b60466-5432-48c9-aedd-1af343e957de/user-cannot-be-found-when-使用-invokecommand-newspsite-on-sharepoint )
  4. 我通过注册表(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"')将powershell设置为默认以管理员身份运行

脚本代码:

  #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

远程 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

提前谢谢了

4

1 回答 1

0

您需要检查 CredSSP 身份验证。使用 SharePoint 执行远程 PowerShell 失败,因为第二个跃点将凭据转换为系统凭据。如果任务涉及查询或更新数据库服务器,它将失败,因为 SYSTEM 帐户将无法访问 SQL Server 上的远程 PowerShell。您需要启用 CredSSP。

查看我不久前写的这篇博文。这不是特定于 SharePoint,但它也应该适用于您的方案。

http://www.ravichaganti.com/blog/?p=1230

于 2013-06-27T06:40:17.367 回答