我想知道如何在Windows10上查看Powershell中所有已安装软件的版本号。我挖出了一个示例,但当我将生成的列表与控制面板>卸载程序中的列表进行比较时,它似乎不完整。例如,查询输出中缺少Google。知道为什么吗?我对Powershell的经验很少,所以可能是一些显而易见的东西?
Get-WMIObject -Query "SELECT * FROM Win32_Product" |FT
Chrome当然已经安装,但没有显示在PS输出中:
发布于 2022-09-24 01:04:37
试试这个:
function Get-InstalledApps {
param (
[Parameter(ValueFromPipeline=$true)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[string]$NameRegex = ''
)
foreach ($comp in $ComputerName) {
$keys = '','\Wow6432Node'
foreach ($key in $keys) {
try {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $comp)
$apps = $reg.OpenSubKey("SOFTWARE$key\Microsoft\Windows\CurrentVersion\Uninstall").GetSubKeyNames()
} catch {
continue
}
foreach ($app in $apps) {
$program = $reg.OpenSubKey("SOFTWARE$key\Microsoft\Windows\CurrentVersion\Uninstall\$app")
$name = $program.GetValue('DisplayName')
if ($name -and $name -match $NameRegex) {
[pscustomobject]@{
ComputerName = $comp
DisplayName = $name
DisplayVersion = $program.GetValue('DisplayVersion')
Publisher = $program.GetValue('Publisher')
InstallDate = $program.GetValue('InstallDate')
UninstallString = $program.GetValue('UninstallString')
Bits = $(if ($key -eq '\Wow6432Node') {'64'} else {'32'})
Path = $program.name
}
}
}
}
}
}
用途:Get-InstalledApps -ComputerName $env:COMPUTERNAME
https://serverfault.com/questions/1111419
复制相似问题