Internet Explorer Version Check via PowerShell

Hello everyone. Recently I have got a task to check the version of Internet Explorer on our Windows Server 2008 R2 machines (yes, we are still using them, loads).

I decided to check the IE via PowerShell ofc. But since I have had like 400 servers, I decided to write a script to connect to the server (ok first to check the connection and see if the server is responding or not), and to query registry, get the result from it, collect all the info, and save it into CSV file. Pretty neat ha? 🙂

OK, so lets get started.

Also check: INSTALLING POWERSHELL 3.0 ON WINDOWS SERVER 2008 R2 SP1

First, we need to know where in Registry we can get the right info. The correct path is: HKLM\Microsoft\Internet Explorer – in there, you will find a ´Value´ section.

Also, I have defined a variable ´computernames´, which we contain computer names taken from computers.txt (you can place your script and txt file wherever you want, I decided to place it in C:_Scripts\check_IE_version).

[php]$array =@()

$keyname = ‘SOFTWARE\\Microsoft\\Internet Explorer’

$computernames = Get-Content "C:\_scripts\check_IE_Version\computers.txt"[/php]

Next, we want to check the connection to all the servers from computer.txt file.

[php]foreach ($computer in $computernames) {

if (!(Test-Connection -CN $computer -BufferSize 16 -Count 1 -ea 0 -quiet))

{

Write-Host "Problem connecting to " $computer

} else {

Write-host "We have a good connection to " $computer

} #end else } #end if[/php]

Basically, it tests the connection to a server ($computer), and in case the server is reachable it replies with ¨We have a good connection to computer this and this, and ofc in case it is not reachable, it responds with ¨problem…¨

Okie, now that we have tested the connection, we can proceed and retrieve the IE version from the reachable servers.

We will connect to the registry on remote machine and collect the info:

[php]$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $computer)

$key = $reg.OpenSubkey($keyname)

$value = $key.GetValue(‘Version’)[/php]

After we have all the info, we will create a new object and add the content:

[php]$obj = New-Object PSObject

$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $computer

$obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value

$array += $obj[/php]

in the end, we will select the two object properties and export it to CSV file:

[php]$array | select ComputerName,IEVersion | export-csv IE_Version.csv[/php]

Voila! That is it. This is how to check which Internet Explorer version do you have on your servers, without need to login to every single one of them.

Here is the complete script, just copy paste to notepad and save it whatever name you want to use. And don´t forget to create computers.txt file and put the server names inside.

[php]$array =@()

$keyname = ‘SOFTWARE\\Microsoft\\Internet Explorer’

$computernames = Get-Content "C:\_scripts\check_IE_Version\computers.txt"

foreach ($computer in $computernames) {

if (!(Test-Connection -CN $computer -BufferSize 16 -Count 1 -ea 0 -quiet))

{

Write-Host "Problem connecting to " $computer

} else {

write-host "We have a good connection to " $computer

} #end else

} #end if

foreach ($computer in $computernames) {

$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $computer)

$key = $reg.OpenSubkey($keyname)

$value = $key.GetValue(‘Version’)

$obj = New-Object PSObject

$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $computer

$obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value

$array += $obj

} #end foreach

$array | select ComputerName,IEVersion | export-csv IE_Version.csv[/php]