In this post i will show you how to get the IE version from remote computers using Powershell.
The way i will do it is with Remote Registry Query, which this can help you for future use and not just for the IE version,
There are two ways to do this, I'm sure you will find them both on the Internet but i though it could be nice to get the both methods on one post.
Option 1: Remote Registry Query Using .Net
#################################################
#################################################
###### Get IE Version From Remote Computer ######
###### .NET ######
#################################################
#################################################
### Important ###
#
# In order to use the .NET framework to open the Registry on
# remote computer the Remote Registry service must be turn on!
#
### Important ###
# Read remote machines from a list
$list = Get-Content C:\Temp\List.txt
# Define the key to retreive
$hklm = "LocalMachine"
$keyname = 'SOFTWARE\\Microsoft\\Internet Explorer'
# Foreach loop for the list of machines,
# and capture the result to a new object for export later to CSV
$CSVOutput = foreach ($machine in $list) {
$output = "" | Select-Object -Property Machine, Value
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($hklm, $machine)
$key = $reg.OpenSubkey($keyname)
# Value to search for under the defined Hive & Key
$value = $key.GetValue('svcVersion')
# On IE11 the value behind the svcVersion key, on lower version the value behind Version,
# So, the below just check if the above $Version is not empty, and if it doesn it means
# we have a lower version. and pull the old Version key.
if ($value -eq $null) {$value = $key.GetValue('Version') } # END IF Get Value
# Push the result to the $Output variable we have created
$output.Machine = $machine
$output.Value = $value
$output
} # END foreach CSVOutput loop
# Change the output path to ever you want
$CSVOutput | Export-Csv C:\Temp\IEVer.csv
Option 2: Remote Registry Query Using WMI
#################################################
#################################################
###### Get IE Version From Remote Computer ######
###### WMI ######
#################################################
#################################################
### WMI Regitry Hive
# HKEY_CLASSES_ROOT (2147483648 (0x80000000))
# HKEY_CURRENT_USER (2147483649 (0x80000001))
# HKEY_LOCAL_MACHINE (2147483650 (0x80000002))
# HKEY_USERS (2147483651 (0x80000003))
# HKEY_CURRENT_CONFIG (2147483653 (0x80000005))
# Read remote machines from a list
$list = Get-Content C:\Temp\List.txt
# Define the key to retreive
$hklm = 2147483650
$key = "SOFTWARE\Microsoft\Internet Explorer"
# Foreach loop for the list of machines,
# and capture the result to a new object for export later to CSV
$CSVOutput = foreach ($machine in $list) {
$output = "" | Select-Object -Property Machine, IEVersion
$wmi = ""
$Version = ""
# Value to search for under the defined Hive & Key
$value = "svcVersion"
# initial the WMI instance & Query the key for a specific value
$wmi = Get-WmiObject -List -Namespace "root\default" -ComputerName $machine | Where-Object {$_.Name -eq "StdRegProv"}
$Version = ($wmi.GetStringValue($hklm,$key,$value)).svalue
# On IE11 the value behind the svcVersion key, on lower version the value behind Version,
# So, the below just check if the above $Version is not empty, and if it doesn
# it means we have a lower version and pull the old Version key.
if ($Version -eq $null) {$value = "Version"; $Version = ($wmi.GetStringValue($hklm,$key,$value)).svalue}
# Push the result to the $Output variable we have created
$output.Machine = $machine
$output.IEVersion = $Version
$output
} # END foreach CSVOutput loop
# Change the output path to ever you want
$CSVOutput | Export-Csv C:\Temp\IEVer.csv
Enjoy!
Improved version with error handling. Original version if no access incorrectly report IE version from previous server (!!).
ReplyDelete#################################################
#################################################
###### Get IE Version From Remote Computer ######
###### .NET ######
#################################################
#################################################
# based on
# http://jerasioren.blogspot.com/2015/03/query-remote-registry-ie-version.html
# TSoucek 20160108
### Important ###
#
# In order to use the .NET framework to open the Registry on
# remote computer the Remote Registry service must be turn on!
#
### Important ###
# Read remote machines from a list
$list = Get-Content .\servers.txt -ErrorAction Stop
# Define the key to retreive
$hklm = "LocalMachine"
$keyname = 'SOFTWARE\\Microsoft\\Internet Explorer'
# Foreach loop for the list of machines,
# and capture the result to a new object for export later to CSV
$CSVOutput = foreach ($machine in $list) {
$output = "" | Select-Object -Property Machine, Value
try {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($hklm, $machine)
}
catch {
Clear-Variable reg
}
try {
$key = $reg.OpenSubkey($keyname)
}
catch {
Clear-Variable key
}
if ($reg -eq $null) {
$value = "-error access machine-"
}
elseif ($key -eq $null) {
$value = "-error access registry-"
}
else {
# Value to search for under the defined Hive & Key
$value = $key.GetValue('svcVersion')
}
# On IE11 the value behind the svcVersion key, on lower version the value behind Version,
# So, the below just check if the above $Version is not empty, and if it doesn it means
# we have a lower version. and pull the old Version key.
if ($value -eq $null) {$value = $key.GetValue('Version') } # END IF Get Value
# Push the result to the $Output variable we have created
$output.Machine = $machine
$output.Value = $value
$output
} # END foreach CSVOutput loop
# Change the output path to ever you want
$CSVOutput | Export-Csv .\IEVer.csv
Great Script, Thanks!
ReplyDelete