You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何借助PowerShell远程(WinRM)完成SharePoint补丁部署?

SharePoint远程补丁部署问题

补丁部署最优顺序

为保证SharePoint补丁安装的稳定性与优化效果,需分批次按以下顺序应用:

  • 操作系统补丁
  • SQL补丁
  • SharePoint补丁

补丁筛选与下载工具

使用PSWindowsUpdate模块简化补丁筛选工作,提前通过该模块或系统内置的WindowsUpdateProvider完成补丁下载。

交互式补丁的远程执行困境

多数SharePoint补丁要求交互式运行,原本可通过计划任务实现,但常规配置要求有权限的用户本地登录,违背远程脚本自动化的初衷。尝试通过S4U(Service For User)登录类型绕过该限制,但配置后仍未解决问题。

关于S4U的网络访问能力存在争议,因此已提前完成补丁下载,排除网络因素影响。

必要权限与环境限制

  • 执行计划任务的账户必须拥有Logon as batch job系统权限
  • 整个网络已禁用传统RPC

已执行的PowerShell脚本

Invoke-Command -ComputerName RemoteSrv -ScriptBlock {
  $SoftwareUpdates = Start-WUScan -SearchCriteria "Type='Software' AND IsInstalled =0"
  Install-WUUpdates -Updates $SoftwareUpdates -DownloadOnly $true | Out-Null

  $Trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddYears(10)

  $Argument = "Install-WindowsUpdate -NotCategory 'Microsoft SQL Server','Office Online Server' -AcceptAll -AutoReboot"

  $Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "$Argument"

  $Principal = New-ScheduledTaskPrincipal `
    -UserId 'domain\userid' `
    -RunLevel Highest `
    -LogonType S4U

  Register-ScheduledTask `
    -TaskPath '\SharePoint\' -TaskName 'PatchSharePoint' `
    -Trigger $Trigger `
    -Principal $Principal `
    -Action $Action `
    -Force | Out-Null

  Start-ScheduledTask -TaskPath '\SharePoint\' -TaskName 'PatchSharePoint'
}

当前问题现象

需要交互式登录的补丁仍未安装,但任务计划程序历史记录显示任务成功完成:

Task Scheduler successfully completed task "\SharePoint\PatchSharePoint", instance "{...},
action "PowerShell.exe" with return code 0.

编辑:已修正脚本参数中的拼写错误。

内容的提问来源于stack exchange,提问作者Dennis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 10:17:40