Solved

Define version IE on computers specific OU

Posted on 2014-02-12
8
548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 29

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 29

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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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
 
LVL 29

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 29

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

732 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