powershell – Win32_Product的替代品?
发布时间:2020-12-13 22:46:12 所属栏目:Windows 来源:网络整理
导读:好吧.在玩了查询Win32_Product以找到软件版本后,我无法理解为什么结果如此慢狗.比查询Win32_service或Win32_process慢15倍.所以来这里看我是否遗漏了什么,我发现其他人报告了同样的问题,这 article解释了原因. 查找已安装软件的最常用的替代方法是查询注册表
好吧.在玩了查询Win32_Product以找到软件版本后,我无法理解为什么结果如此慢狗.比查询Win32_service或Win32_process慢15倍.所以来这里看我是否遗漏了什么,我发现其他人报告了同样的问题,这
article解释了原因.
查找已安装软件的最常用的替代方法是查询注册表项或三个.这将是我的第一个解决方案,除了我的公司尚未配置服务器接受PSRemoting.任何reg查询只返回Kerberos身份验证错误.我可以在各个服务器上启用PSRemoting,但我的团队支持30K系统.所以解决方案就出来了. 最重要的是,我们正在将Symantec Endpoint Protection从v.11升级到v.12,我想要一个简单的检查来查找服务器上安装的版本.除了Win32_Product和注册表查询之外,还有其他选择吗?
我远程使用注册表,没有PSRemoting.这是我编写的函数,每天用于查询软件.
Function Get-RemoteSoftware{ <# .SYNOPSIS Displays all software listed in the registry on a given computer. .DESCRIPTION Uses the SOFTWARE registry keys (both 32 and 64bit) to list the name,version,vendor,and uninstall string for each software entry on a given computer. .EXAMPLE C:PS> Get-RemoteSoftware -ComputerName SERVER1 This shows the software installed on SERVER1. #> param ( [Parameter(mandatory=$true,ValueFromPipelineByPropertyName=$true)][string[]] # Specifies the computer name to connect to $ComputerName ) Process { foreach ($Computer in $ComputerName) { #Open Remote Base $reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$Computer) #Check if it's got 64bit regkeys $keyRootSoftware = $reg.OpenSubKey("SOFTWARE") [bool]$is64 = ($keyRootSoftware.GetSubKeyNames() | ? {$_ -eq 'WOW6432Node'} | Measure-Object).Count $keyRootSoftware.Close() #Get all of they keys into a list $softwareKeys = @() if ($is64){ $pathUninstall64 = "SOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall" $keyUninstall64 = $reg.OpenSubKey($pathUninstall64) $keyUninstall64.GetSubKeyNames() | % { $softwareKeys += $pathUninstall64 + "" + $_ } $keyUninstall64.Close() } $pathUninstall32 = "SOFTWAREMicrosoftWindowsCurrentVersionUninstall" $keyUninstall32 = $reg.OpenSubKey($pathUninstall32) $keyUninstall32.GetSubKeyNames() | % { $softwareKeys += $pathUninstall32 + "" + $_ } $keyUninstall32.Close() #Get information from all the keys $softwareKeys | % { $subkey=$reg.OpenSubKey($_) if ($subkey.GetValue("DisplayName")){ $installDate = $null if ($subkey.GetValue("InstallDate") -match "/"){ $installDate = Get-Date $subkey.GetValue("InstallDate") } elseif ($subkey.GetValue("InstallDate").length -eq 8){ $installDate = Get-Date $subkey.GetValue("InstallDate").Insert(6,".").Insert(4,".") } New-Object PSObject -Property @{ ComputerName = $Computer Name = $subkey.GetValue("DisplayName") Version = $subKey.GetValue("DisplayVersion") Vendor = $subkey.GetValue("Publisher") UninstallString = $subkey.GetValue("UninstallString") InstallDate = $installDate } } $subkey.Close() } $reg.Close() } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows-8 – 单击“单击此处查看完整报告”后出现Windows
- xaml – 按钮样式看起来像应用程序栏按钮
- Windows Azure表存储帐户的限制
- Windows 7风格通知在Delphi中的弹出窗口
- 如何在Windows上使用Perl在命令行上处理通配符?
- installer – WiX – 在主要升级时保留注册表设置
- windows-7 – 从Windows 7到ASA 5520的L2TP / IPSec
- windows-server-2003 – 如何禁用系统服务监听Windows Serv
- windows-server-2008-r2 – 阻止用户在特定目录中保存具有特
- Windows下svn import(将网站文件导入仓库)的方法
推荐文章
站长推荐
- windows-server-2003 – 2k3到2k12 AD,DC和DNS迁
- 08、组策略管理
- Windows10的任务管理器方块没对齐,犯强迫症了
- windows – tnsping ping失败,即使我可以成功连接
- 批处理文件 – 如何使用批处理作为exe执行dll
- windows-server-2012-r2 – 如何使Windows服务器
- windows – 自动重新启动Perfmon数据收集器集
- windows – 想要抑制文件未找到输出
- Windows – IIS NTLM / Kerberos身份验证是否仍适
- windows-installer – 将MSIUSEREALADMINDETECTI
热点阅读