【问题标题】:Can I get PatchCodeGUID with Powershell?我可以使用 Powershell 获取 PatchCodeGUID 吗?
【发布时间】:2015-11-11 22:18:12
【问题描述】:

要获取 PatchCodeGUID,我使用脚本:

$vbsCode = @"
Set msi = CreateObject("WindowsInstaller.Installer")
Set patchlist = msi.Patches("{786970C5-E6F6-4A41-B238-AE25D4B91EEA}")
For Each p In patchlist
    WScript.Echo p
Next
"@

$VBSFile = "$env:TEMP\temp.vbs"

$vbsCode | out-file -FilePath $VBSFile
$PatchList = cscript.exe $VBSFile | Where-Object {$_ -match "^{" }
$VBSFile | Remove-Item -Force -ErrorAction SilentlyContinue

$PatchList

是否可以摆脱 VBS 并仅使用 Powershell ?

附: {786970C5-E6F6-4A41-B238-AE25D4B91EEA} 是 SCOM 代理的 RTMProductCodeGuid

【问题讨论】:

    标签: powershell vbscript com


    【解决方案1】:

    您可以使用第三方模块Windows Installer PowerShell Module。它有 CmdLet Get-MSIPatchInfo 应该给你正确的信息(更多信息:http://psmsi.codeplex.com/wikipage?title=Get-MSIPatchInfo.v2.3.0.0&referringTitle=Help.v2.3.0):

    Get-MSIPatchInfo [[-ProductCode] <string[]>] [[-PatchCode] <string[]>] [-Filter <PatchStates>] [-UserContext <UserContexts>] [-UserSid <string>] [-Everyone] [<CommonParameters>]
    

    【讨论】:

      猜你喜欢
      • 2011-03-20
      • 1970-01-01
      • 2020-10-04
      • 2012-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多