【发布时间】:2012-03-01 20:21:11
【问题描述】:
在我们的虚拟机中,我们将查看特定日期安装/卸载的应用程序
有没有办法自动找到呢?
【问题讨论】:
标签: powershell batch-file installation powershell-2.0
在我们的虚拟机中,我们将查看特定日期安装/卸载的应用程序
有没有办法自动找到呢?
【问题讨论】:
标签: powershell batch-file installation powershell-2.0
WMI 接口应该适用于此。使用命令行:wmic product
这里有一个blog article,它更详细地描述了它以及如何以 .csv 文件的形式获取结果。
【讨论】:
我认为您无法找到有关已卸载应用程序的信息,但您可以从注册表中获取一些信息(使用 WMI,您只能获取 MSI 包):
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*\' | Select-Object DisplayName,InstallDate,Publisher
【讨论】:
要获取 msiexec 在特定日期安装的应用程序列表,请使用以下命令:
$strComputer = "."
$colItems = get-wmiobject -class "Win32_Product" -namespace "root\CIMV2" -computername $strComputer
$colitems | ? { $_.installdate -eq "yyyymmdd" }| select name
这适用于所有已安装的应用程序一个 Microsoft KB(需要按日期过滤):
$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall
$Items = $keys |foreach-object {Get-ItemProperty $_.PsPath}
$items | select displayname , "(default)" , installdate
对于未安装的应用程序,您需要从源“MsiInstaller”查询application events logs,或在事件描述中“卸载”的“字符串搜索”。
【讨论】:
Win32_Product 类的查询速度非常慢。尽可能多地过滤。
$computername="SomeServer"
$apps=get-wmiobject win32_product -filter "installdate='20120206'" -computer $computername
【讨论】: