[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Define version IE on computers specific OU

Posted on 2014-02-12
8
Medium Priority
?
560 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 2000 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

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

873 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