【发布时间】:2014-11-14 02:25:18
【问题描述】:
我正在尝试编写一个脚本,该脚本通过使用 Get-WmiObject -Class Win32_Product 获取 IdentificationNumber 来卸载 Microsoft Office 2007 Enterprise。我能够获取 IdentificationNumber,但是当我尝试卸载 PowerShell 时会输出一些我不确定如何处理的信息。这不是使用 Uninstall() 的正确方法吗?
$2k7 = Get-WmiObject -Class Win32_Product | Where-Object { $_.IdentifyingNumber -match "{90120000-0030-0000-0000-0000000FF1CE}" }
if ($2k7 -ne $null) {
$2k7.Uninstall()
}
else {
write-host "nothing to see here"
}
输出...
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 1603
【问题讨论】:
-
1603 表示发生了致命错误。您应该可以使用
.Uninstall。我想知道是否还有其他原因导致它无法正常工作。如果您尝试在同一脚本中msiexec.exe /x {90120000-0030-0000-0000-0000000FF1CE} /quiet会发生什么?我想你有另一个不是脚本错误的问题。 -
以前当我尝试调用 msiexec /x 时,它会弹出 msiexec 帮助框,指示 /x 或 /uninstall 标志存在问题。然而,现在这样做似乎有效。感谢您的帮助!