1

是否可以获得远程计算机已安装软件的列表?我知道使用 Powershell 对本地计算机执行此操作。是否可以使用 Powershell 获取远程计算机的已安装软件并将此列表保存在远程计算机上?这我用于本地计算机:Get-WmiObject -Class Win32_Product | 选择对象-属性名称

在此先感谢,最好的问候,

4

2 回答 2

3

这使用 Microsoft.Win32.RegistryKey 检查远程计算机上的 SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 注册表项。

https://github.com/gangstanthony/PowerShell/blob/master/Get-InstalledApps.ps1

*编辑:粘贴代码以供参考

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
                    }
                }
            }
        }
    }
}
于 2016-01-15T16:42:57.233 回答
1

有多种方法可以获取远程计算机上已安装软件的列表:

  1. 在 ROOT\CIMV2 命名空间上运行 WMI 查询:

    • 启动 WMI Explorer 或任何其他可以运行 WMI 查询的工具。
    • 运行 WMI 查询“SELECT * FROM Win32_Product”
  2. 使用 wmic 命令行界面:

    • 按 WIN+R
    • 输入“wmic”,回车
    • 在 wmic 命令提示符中键入“/node:RemoteComputerName 产品”
  3. 使用 Powershell 脚本:

    • 通过 WMI 对象:Get-WmiObject -Class Win32_Product -Computer RemoteComputerName
    • 通过注册表:Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall* | 选择对象 DisplayName、DisplayVersion、Publisher、InstallDate | 格式表 –AutoSize
    • 通过 Get-RemoteProgram cmdlet:Get-RemoteProgram -ComputerName RemoteComputerName

来源:https ://www.action1.com/kb/list_of_installed_software_on_remote_computer.html

于 2017-12-13T00:46:03.440 回答