powershell - 通过 powershell 脚本 (MSIEXEC) 卸载补丁
问题描述
我对powershell有点陌生,我试图自动化一个卸载补丁,这样我就可以安装另一个补丁(使用jenkins等~)。
我有这个脚本,它可以获取 ProductID 编号,并且我也有补丁 .msp 文件的路径。将这些变量传递给 msiexec 命令不起作用。我一直收到错误:“无法打开此安装包。请验证该包是否存在~”。
虽然,如果我在不将变量传递给 msiexec 的情况下运行命令,它可以工作。
这是我的脚本:
$PATHPreviousPatch = "<>" #this is where I keep the .msp files to the patch that im trying to uninstall
$IdNumber = Get-WmiObject -Class Win32_Product | Where-Object -FilterScript {$_.Name -eq "%product Example%"} | Format-List -Property IdentifyingNumber
$strProductCode = $IdNumber | Out-String
$strProductCode -match "IdentifyingNumber : (?<content>.*)"
$strProductCode = $Matches['content']
[string]$AppMSP = Get-ChildItem $PATHPreviousPatch| Where-Object {$_.Name -match "%appmsp%.msp"}
$fullUninstallPath = $PATHPreviousPatch + $AppMSP #just to get the full path to the MSP file
msiexec /package `'$strProductCode`' /uninstall """$fullUninstallPath"""
请帮忙,我已经尝试了我能找到的一切..
提前致谢。
解决方案
推荐阅读
- android - 如何在继续之前等待 Java 类的活动完成?
- bash - 创建新 pod 时如何更新 pod 中的 /etc/hosts 文件
- continuous-integration - Teamcity 在单一构建配置中使用特定的 VCS 根作为提示参数
- r - 使用 R 访问 PERSIANN 降雨数据文件(.bin 到栅格)
- amazon-web-services - 使用 Lamda 函数 (Python/Node) 查找 DynomoDB 表项中的对象数
- python - Scipy 的solve_ivp 似乎无法处理其他参数
- php - 在 PHP 中通过关联数组循环时获得两个结果
- python - 使用 City 和 State 列查找纬度和经度
- python - opencv中的imshow()函数在Windows上不起作用
- javascript - 是否可以在 Babel 中运行 ES6 代码而不将其转换为 ES5