How to Get Firefox Version in Local and Remote Computer Using PowerShell
Problem
In this blog post, we will walk you through how to get Firefox version using PowerShell from your local and remote computer.
Get Firefox Version from Local Computer
Using Get-ItemPropertyValue cmdlet
Firefox version can be found at HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox
registry key.
You can use Get-ItemPropertyValue
cmdlet to get the registry key value by specifying the registry key path and name.
Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Mozilla\Mozilla Firefox' -Name "CurrentVersion"
Using Get-Item cmdlet to Get VersionInfo
You can also use Get-Item
cmdlet to get Firefox version by locating the executable file in installation folder. Then, you can select its VersionInfo
.
(Get-Item "C:\Program Files\Mozilla Firefox\firefox.exe").VersionInfo
Get Firefox Version from Remote Computer
To connect to remote computer, we can use Enter-PSSession
that will create interactive session or Invoke-Command
which is not interactive.
In this context, we have two computers named vm1
and vm2
respectively. The client will be vm1
and we will get Firefox version information on vm2
machine.
Since the computers are not in the same domain, we should use Windows Remote Management (WinRM) for remote communication or remoting.
Below are several prerequisites to use WinRM for remote communication:
- Enable Windows Remote Management (WinRM) service on both computers (
vm1
andvm2
)
Set-Service -Name WinRM -Status Running -StartupType Automatic
- Add servers we want to connect to
TrustedHosts
list on client computer, i.e., apply below script tovm1
Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value 'vm2'
- Enable firewall rule for WinRM to allow other IPs to connect on remote computer, so apply below script to
vm2
Set-NetFirewallRule -Name 'WINRM-HTTP-In-TCP' -RemoteAddress Any
Enable-NetFirewallRule -Name 'WINRM-HTTP-In-TCP'
Or you can also do it manually:
1. Open Windows Defender Firewall with Advanced Security
2. Click Inbound Rules
3. Double-click Windows Remote Management (HTTP-In) for the Public profile
4. Click the Scope tab
5. Under Remote IP address, set it to `Any IP Address`
6. Enable Rule
Using Enter-PSSession cmdlet
To create session to remote computer, first you need to run Enter-PSSession
and specify the computer name we want to connect as well as the credential (username and password).
Enter-PSSession vm2 -Credential (Get-Credential)
Secondly, after connected we can execute the script to get Firefox version on vm2
machine just like we do on local computer as follows:
Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Mozilla\Mozilla Firefox' -Name "CurrentVersion"
Or
(Get-Item "C:\Program Files\Mozilla Firefox\firefox.exe").VersionInfo
You can read more details regarding some ways to get Firefox version using PowerShell.
Lastly, to close the session we use Exit-PSSession
cmdlet.
Exit-PSSession
Using Invoke-Command cmdlet
With this cmdlet, you won’t have interactive session. The Get-ItemPropertyValue
cmdlet will be executed in one go in a ScriptBlock
.
Invoke-Command -ComputerName vm2 -ScriptBlock {
Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Mozilla\Mozilla Firefox' -Name "CurrentVersion"
} -Credential (Get-Credential)
You can read more details regarding some ways to get Firefox version using PowerShell.
You still have to enter credential before the ScriptBlock is executed.
The result will look as follows:
Conclusion
To get Firefox version, you can use Get-ItemPropertyValue
or Get-Item
cmdlet.
To get Firefox version on remote computer, first we need to establish connection to remote computer (remoting). If the computers are not in the same domain, we should use Windows Remote Management (WinRM).
Then, we can use Enter-PSSession
to create interactive session or Invoke-Command
that will invoke the script in one go. These methods later will be combined with Get-ItemPropertyValue
or Get-Item
cmdlet to get Firefox version on remote computer.