Solved

Define version IE on computers specific OU

Posted on 2014-02-12
8
519 Views
Last Modified: 2014-02-20
Hi folks,

How might look script allowing to define version of Internet Explorer. on computers of specific organizational unit, considering the fact that IE maybe is embedded in the windows and maybe installed via windows update.

thanks
0
Comment
Question by:nesher13
  • 4
  • 4
8 Comments
 
LVL 28

Expert Comment

by:becraig
ID: 39854494
There is already a script out there to get IE version as it is recorded in the registry:

The approach would be:
1) do a get-adcomputer based on OU
2) filter that into a foreach loop and record the version:

$array =@() 
$keyname = 'SOFTWARE\\Microsoft\\Internet Explorer' 
$computernames = Get-ADComputer -Filter * | Where { $_.DistinguishedName -like "*$OU*" } 
#note there have been issues with using the -liek approach but it works for me
#you could probaby try  Get-ADComputer -SearchBase "ou=Grou,dc=demo,dc=com" 
foreach ($server in $computernames) 
{ 
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server) 
$key = $reg.OpenSubkey($keyname) 
$value = $key.GetValue('Version') 
 $obj = New-Object PSObject          
        $obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $server          
        $obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value  
        $array += $obj  
 
}  
$array | select ComputerName,IEVersion | export-csv IE_Version.csv

Open in new window

0
 

Author Comment

by:nesher13
ID: 39858631
becraig,


Open in new window

$array =@()
$keyname = 'SOFTWARE\\Microsoft\\Internet Explorer'
#$computernames = Get-ADComputer -Filter * | Where { $_.DistinguishedName -like "*$OU*" }
#note there have been issues with using the -liek approach but it works for me
#you could probaby try  Get-ADComputer -SearchBase "ou=Grou,dc=demo,dc=com"
$computernames = Get-ADComputer -Filter * -SearchBase "ou=w7,dc=demo,dc=com
foreach ($server in $computernames)
{
#$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server)
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::'LocalMachine', $server)
$key = $reg.OpenSubkey($keyname)
$value = $key.GetValue('Version')
 $obj = New-Object PSObject          
        $obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $server          
        $obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value  
        $array += $obj  
 
}  
$array | select ComputerName,IEVersion | export-csv c:\Powershell\IE_Version.csv

Open in new window


I almost used your script, but I get error messages:

Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Powershell\Scripts\IE-version.ps1:10 char:1
+ $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.Registr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException
 
You cannot call a method on a null-valued expression.
At C:\Powershell\Scripts\IE-version.ps1:11 char:1
+ $key = $reg.OpenSubkey($keyname)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Powershell\Scripts\IE-version.ps1:12 char:1
+ $value = $key.GetValue('Version')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Powershell\Scripts\IE-version.ps1:10 char:1
+ $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.Registr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

You cannot call a method on a null-valued expression.
At C:\Powershell\Scripts\IE-version.ps1:11 char:1
+ $key = $reg.OpenSubkey($keyname)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Powershell\Scripts\IE-version.ps1:12 char:1
+ $value = $key.GetValue('Version')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Powershell\Scripts\IE-version.ps1:10 char:1
+ $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.Registr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException
 
You cannot call a method on a null-valued expression.
At C:\Powershell\Scripts\IE-version.ps1:11 char:1
+ $key = $reg.OpenSubkey($keyname) ...

and so on
0
 
LVL 28

Expert Comment

by:becraig
ID: 39859526
I did not include the select object for the computer name so it was actually trying to do a remote registry query for the entire DN.

Here is the updated version:

$array =@() 
$computernames = Get-ADComputer -Filter * | where {$_.distinguishedName -like "*OU=OuName,DC=DC,DC=DC*" } | select-object -expa Name
foreach ($server in $computernames) 
{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server) 
$key = $reg.OpenSubkey("SOFTWARE\Microsoft\Internet Explorer") 
$value = $key.GetValue('Version') 
 $obj = New-Object PSObject          
        $obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $server          
        $obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value  
        $array += $obj  
 
}  
$array | select ComputerName,IEVersion | export-csv IE_Version.csv

Open in new window

0
 

Author Comment

by:nesher13
ID: 39860622
becraig

I am sorry, but I have found that on the remote computers  service  Remote Registry  was set to manual.  if you do not mind, let's continue our discussion after weekend.

Happy weekend!
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 28

Expert Comment

by:becraig
ID: 39860635
Ok np.

If you need to start remote registry on multiple servers you can just send a start control

for /f  %a in (listofservers.txt) do sc \\%a start remoteregistry  (if it is set to manual)
IF it is disabled you can run the below commands

for /f  %a in (listofservers.txt) do sc \\%a config remoteregistry start= manual
for /f  %a in (listofservers.txt) do sc \\%a start remoteregistry
0
 

Author Comment

by:nesher13
ID: 39870197
becraig

The test results revealed that:

1. it is necessary to use the "svcVersion" or "svcUpdateVersion" properties rather than the property "Version"

2. Output gives version of IE on the local machine which run the script
0
 
LVL 28

Accepted Solution

by:
becraig earned 500 total points
ID: 39870639
I am not sure why you get the local version I just re-ran using the script and this is my output against 4 servers :

"ComputerName","IEVersion"
"Computer1","9.0.24"
"Computer2","9.0.24"
"Computer3","10.0.13"
"Computer4","9.0.24"


Here is the script used.

$array =@() 
$computernames = Get-ADComputer -Filter * | where {$_.distinguishedName -like "*OU=Accounting,OU=Services,OU=Companyarm,OU=branchoffice,OU=Properties,DC=contoso,DC=local*" } | select-object -expa Name
foreach ($server in $computernames) 
{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server) 
$key = $reg.OpenSubkey("SOFTWARE\Microsoft\Internet Explorer") 
$value = $key.GetValue('svcUpdateVersion') 
 $obj = New-Object PSObject          
        $obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $server          
        $obj | Add-Member -MemberType NoteProperty -Name "IEVersion" -Value $value  
        $array += $obj  
 
}  
$array | select ComputerName,IEVersion | export-csv IE_Version.csv
                 

Open in new window

0
 

Author Comment

by:nesher13
ID: 39874631
becraig

thank you very match

It is working
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now