Solved

Define version IE on computers specific OU

Posted on 2014-02-12
8
535 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
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

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell Script Help 1 31
format log file 2 20
How to get user domain by Powershell from their email address? 10 33
Tricky powershell this time 4 25
Utilizing an array to gracefully append to a list of EmailAddresses
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
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…

839 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