检查和Web浏览器安装在Windows Server 2008/2012/2016上

问题描述 投票:0回答:1

我正在尝试编写一个简短的Powershell脚本,该脚本遍历服务器列表并检查是否安装了Web浏览器或Web浏览器。

我可以使用以下命令查询已安装的应用程序列表,但是如果服务器上未安装Internet Explorer,则不会显示。

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*Internet Explore*"} | Select-Object -ExpandProperty DisplayName

如果安装了浏览器,是否有更好的方法来查询注册表值true / false?

还有一种更好的方法来获取Windows Server上安装的浏览器列表,而不是使用“HKLM:\ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall *”。是否有可以查询的Windows Server上的Web浏览器的替代注册位置?

powershell windows-server
1个回答
0
投票
Function Test-RegValue
{
param([string]$RegKeyPath,[string]$Value)
    if(test-path $RegKeyPath)
    {
        (Get-ItemProperty $RegKeyPath).$Value -ne $null

    }
    else
    {
        $false
    }

}

Test-RegValue -RegKeyPath "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8E3C7B5F-362C-440E-9895-726083B802E1}"  -Value displayname

如果存在根密钥,那么我们检查属性“displayname”是否有值。在我的电脑上,这个8E3C7B5F-362C-440E-9895-726083B802E1 reg键对应于“node.js”

所以只需列出各种浏览器的reg键ID,并将它们作为参数值传递给regkeypath

© www.soinside.com 2019 - 2024. All rights reserved.