PowerShell 技能连载 - 读取已安装的软件(第 1 部分)

Get-ItemProperty cmdlet 可以比大多数用户知道的功能强大得多的方式读取注册表值。该 cmdlet 支持多个注册表路径,并且支持通配符。这样,只需一行代码即可从四个注册表项读取所有已安装的软件(及其卸载字符串):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# list of registry locations where installed software is stored
$paths =
# all users x64
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
# all users x86
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*',
# current user x64
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
# current user x86
'HKCU:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'

Get-ItemProperty -ErrorAction Ignore -Path $paths |
# eliminate all entries with empty DisplayName
Where-Object DisplayName |
# select some properties (registry values)
Select-Object -Property DisplayName, DisplayVersion, UninstallString, QuietUninstallString

PowerShell 技能连载 - 读取已安装的软件(第 1 部分)

http://blog.vichamp.com/2020/12/18/reading-installed-software-part-1/

作者

吴波

发布于

2020-12-18

更新于

2022-07-06

许可协议

评论