Powershell 从远程计算机获取google chrome版本

Powershell 从远程计算机获取google chrome版本,powershell,Powershell,我需要生成不同计算机上已安装的google chrome版本列表。 根据这方面的最佳答案,我得出了以下代码: $machines = Get-content -Path C:\Users\user\Desktop\machines.txt ForEach($machine in $machines){ $Version = gwmi win32_product -ComputerName $machine -Filter "Name='Google Chrome'" | Select

我需要生成不同计算机上已安装的google chrome版本列表。 根据这方面的最佳答案,我得出了以下代码:

$machines = Get-content -Path C:\Users\user\Desktop\machines.txt

ForEach($machine in $machines){
    $Version = gwmi win32_product -ComputerName $machine -Filter "Name='Google Chrome'" | Select -Expand Version
    "$machine - $Version"
}
我不知道为什么$Version是完全空的,并且没有返回值。看起来这个脚本根本找不到谷歌浏览器

试试这个

$machines = Get-content -Path C:\Users\user\Desktop\machines.txt

ForEach($machine in $machines){
    $Version = (Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo
    "$machine - $Version"
}

这似乎对我有用

$machines = Get-content -Path C:\Users\user\Desktop\machines.txt
ForEach($machine in $machines){
$Version = Invoke-command -computer $machine {(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo}
"$machine - $Version"
}

但这不支持远程检查,是吗?它只是对机器的数量运行相同的命令,但每次都不更改机器。可能会添加Invoke命令?它不会检查给定的机器,而是在我的计算机上反复检查$路径中未使用计算机您的计算机是否支持远程wmi DCOM?您可以尝试获取ciminstance而不是WINRM。答案不应该是简单的代码片段。你能详细说明这段特定代码为什么以及如何回答这个问题吗?上面的版本有正确的上下文,但它们没有使用invoke命令方法来发送命令。发生的事情是,他们正在查询本地机器。这段代码应该按照上面的要求运行。他/她非常接近答案。