【问题标题】:Get software center updates install status from sccm client using powershell使用 powershell 从 sccm 客户端获取软件中心更新安装状态
【发布时间】:2018-05-17 19:17:36
【问题描述】:

我想获取 SCCM 客户端软件中心当前所有补丁的实时状态。我尝试使用我在网上找到的多个脚本,但最终都没有向我显示实时结果。我可以获得所有当前可用的更新及其相应的软件更新组,这些更新组正在部署那些缺失的补丁,但还没有发现如何将缺失的补丁链接到它们当前的状态,就像软件中心目前所做的那样。

下面的功能目前有效,是我用来安装缺失补丁的工具。

Function Install-SCCMPatchesAvailable {
  [CmdletBinding()]
  param(
    [Parameter(
      Position = 0,
      Mandatory = $false,
      ValueFromPipelineByPropertyName = $true,
      HelpMessage = "Do not reboot server after patches install")]
    [ValidateNotNullOrEmpty()]
    [switch]
    $DoNotReboot
  )

  begin {
    Write-Verbose "Install-SCCMPatchesAvailable: Started"
  }

  process {
    try {
      ([wmiclass]'ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager').InstallUpdates([System.Management.ManagementObject[]] `
        (Get-WmiObject -Query 'SELECT * FROM CCM_SoftwareUpdate' -namespace 'ROOT\ccm\ClientSDK'))

      while (-not((Get-WmiObject -Namespace 'ROOT\ccm\ClientSDK' -Class 'CCM_ClientUtilities' -list).DetermineIfRebootPending().RebootPending)) {
        $Time = (get-date).ToShortTimeString()
        Write-Output "Still Patching @ $Time"
        Start-Sleep -s 60
      }
      if (-not $PSBoundParameters.ContainsKey('DoNotReboot')) {
        if ((Get-WmiObject -Namespace 'ROOT\ccm\ClientSDK' -Class 'CCM_ClientUtilities' -list).DetermineIfRebootPending().RebootPending) {
          (Get-WmiObject -Namespace 'ROOT\ccm\ClientSDK' -Class 'CCM_ClientUtilities' -list).RestartComputer()
        }
      }
    }
    catch {
      Write-Error -Message "Something went wrong with Install-SCCMPatchesAvailable.`n`nError.Exception.Message : $($_.Exception.Message)`nError.Exception.FullName: $($_.Exception.GetType().FullName)"
    }
  }

  end {
    Write-Verbose "Install-SCCMPatchesAvailable: Completed"
  }
} #End Install-SCCMPatchesAvailable

我想更换:

$Time = (get-date).ToShortTimeString()
Write-Output "Still Patching @ $Time"
Start-Sleep -s 60

显示 sccm 软件中心列出的补丁程序及其相应的补丁程序状态(下载、安装、等待验证、需要重新启动等),软件中心使用其 GUI 界面显示。

我还可以使用我编写的返回一个或多个缺失补丁对象的模块查看任何缺失的更新。但是,对象的Status 只能显示MissingInstalled。不是补丁的实际 SCCM 状态。示例:

SCCMPatchDeploymentName  : .MS_Server_Engineering_Patch_Testing - Post Basline OSs QAC 
                           Testing
ComputerName             : FSL04231
__GENUS                  : 2
__CLASS                  : CCM_UpdateStatus
__SUPERCLASS             : 
__DYNASTY                : CCM_UpdateStatus
__RELPATH                : CCM_UpdateStatus.UniqueId="5dc25e3e-31b9-4ac7-b1b7-a62a982139
                           0d"
__PROPERTY_COUNT         : 15
__DERIVATION             : {}
__SERVER                 : FSL04231
__NAMESPACE              : ROOT\ccm\SoftwareUpdates\UpdatesStore
__PATH                   : \\FSL04231\ROOT\ccm\SoftwareUpdates\UpdatesStore:CCM_UpdateSt
                           atus.UniqueId="5dc25e3e-31b9-4ac7-b1b7-a62a9821390d"
Article                  : 4088787
Bulletin                 : 
ExcludeForStateReporting : False
Language                 : 
ProductID                : 0fa1201d-4330-4fa8-8ae9-b877473b6441
RevisionNumber           : 202
ScanTime                 : 20180516214114.000000+000
Sources                  : {{7D052A75-2032-4F02-BAC9-9EDA4DBD58DE}}
SourceType               : 2
SourceUniqueId           : {7D052A75-2032-4F02-BAC9-9EDA4DBD58DE}
SourceVersion            : 82
Status                   : Missing
Title                    : 2018-03 Cumulative Update for Windows Server 2016 for 
                           x64-based Systems (KB4088787)
UniqueId                 : 5dc25e3e-31b9-4ac7-b1b7-a62a9821390d
UpdateClassification     : 0fa1201d-4330-4fa8-8ae9-b877473b6441
PSComputerName           : FSL04231

【问题讨论】:

  • 我不太明白。您已经知道您想要的状态(正在下载、安装、等待验证、需要重新启动等)是 CCM_SoftwareUpdate 的评估状态,那么您还在寻找什么?您只需要将 evalstate 转换为人类可读形式的代码吗?
  • 我和你一样想知道远程软件中心的更新安装状态。你有没有找到任何你正在寻找的“工具”或 PS?非常感谢纳乔

标签: powershell sccm patch


【解决方案1】:

软件中心显示软件安装和广告的进度。它不显示除了已安装/丢失之外的补丁状态,所以我怀疑如果您想枚举该补丁的进度状态,您需要抓取日志以确定客户端是否对每个相应的补丁执行任何操作以创建计算运行时的状态消息。

【讨论】:

  • 软件中心显示的不仅仅是安装/缺失。关于补丁的软件中心可以显示以下评估状态列表。 12=InstallComplete 11=Verifying 10=WaitReboot 9=PendingHardReboot 8=PendingSoftReboot 7=安装 6=WaitInstall 5=Downloading 4=PreDownload 3=Detecting 2=Submitted 1=Available 0=None
  • AFAIK 这些状态仅限于软件部署和安装。如果您想了解 Windows 更新的状态,而不是开箱即用提供的合规性状态,您需要在运行时通过抓取日志来计算它。您可以在此处阅读有关该过程的更多信息:docs.microsoft.com/en-us/sccm/sum/understand/…
猜你喜欢
  • 2013-08-15
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 2020-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多