script to find if office version

Hello experts,

I want to pull a report in the form of a csv from users computers that will show what version of MS Office is installed.

I am not sure what to use and I will appreciate if I can have simple script.

Thank u,
LVL 4
Habib ZakariaNetwork Solutions ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Habib ZakariaNetwork Solutions ArchitectAuthor Commented:
it did not work actually. Is there a manual way to do this ?
0
AlexiosCommented:
Try to query the system registry entries using command line.

To get the windows version using System registry , use the following command:

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductName"
This will give an output which can be parsed to get the current windows version/name.

To get the current office version , use:

reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer"
The output of this command gives the office version in number format such as 14, 15, etc.

Parse the output to get the version number and match against the list of existing Microsoft office versions to get the name of the version installed:

Office 97   -  7.0
Office 98   -  8.0
Office 2000 -  9.0
Office XP   - 10.0
Office 2003 - 11.0
Office 2007 - 12.0
Office 2010 - 14.0
Office 2013 - 15.0
1
Introducing the "443 Security Simplified" Podcast

This new podcast puts you inside the minds of leading white-hat hackers and security researchers. Hosts Marc Laliberte and Corey Nachreiner turn complex security concepts into easily understood and actionable insights on the latest cyber security headlines and trends.

Habib ZakariaNetwork Solutions ArchitectAuthor Commented:
My tech will need to query the registry remotely . How will he connect? By not interrupting the user.
0
AlexiosCommented:
Use the information provided in this Microsoft link
https://technet.microsoft.com/en-us/library/cc742028.aspx
0
David Johnson, CD, MVPOwnerCommented:
add Office 2016      Word.Application.16
the remote registry service must be enabled to query remote machines.
<#
.Synopsis
   Get-OfficeVersion 
.DESCRIPTION
   Gets the Office version from a list of computernames and returns a CSV of the Computername and Office Version (if available)
.EXAMPLE
 get-officeversion c:\test\servers.txt c:\test\officeversions.csv
.EXAMPLE
 get-officeversion -infile c:\test\servers.txt -outfile c:\test\officeversions.csv
.NOTES
   General notes
#>
function Get-OfficeVersion
{
param(
    [Parameter(Mandatory=$true)]
    [string] $Infile,
    [Parameter(Mandatory=$true)]
    [string] $outfile
    )
#$outfile = 'C:\temp\office.csv'
#$infile = 'c:\temp\servers.txt'
Begin
    {
    }
 Process
    {
    $office = @()
    $computers = Get-Content $infile
    $i=0
    $count = $computers.count
    foreach($computer in $computers)
     {
     $i++
     Write-Progress -Activity "Querying Computers" -Status "Computer: $i of $count " `
      -PercentComplete ($i/$count*100)
        $info = @{}
        $version = 0
        try{
          $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer) 
          $reg.OpenSubKey('software\Microsoft\Office').GetSubKeyNames() |% {
            if ($_ -match '(\d+)\.') {
              if ([int]$matches[1] -gt $version) {
                $version = $matches[1]
              }
            }    
          }
          if ($version) {
            Write-Debug("$computer : found $version")
            switch($version) {
                "7" {$officename = 'Office 97' }
                "8" {$officename = 'Office 98' }
                "9" {$officename = 'Office 2000' }
                "10" {$officename = 'Office XP' }
                "11" {$officename = 'Office 97' }
                "12" {$officename = 'Office 2003' }
                "13" {$officename = 'Office 2007' }
                "14" {$officename = 'Office 2010' }
                "15" {$officename = 'Office 2013' }
                "16" {$officename = 'Office 2016' }
                default {$officename = 'Unknown Version'}
            }
    
          }
          }
          catch{
              $officename = 'Not Installed/Not Available'
          }
    $info.Computer = $computer
    $info.Name= $officename
    $info.version =  $version

    $object = new-object -TypeName PSObject -Property $info
    $office += $object
    }
    $office | select computer,version,name | Export-Csv -NoTypeInformation -Path $outfile
    }
}
  write-output ("Done")

Open in new window

get-officeversion.ps1..txt
0
David Johnson, CD, MVPOwnerCommented:
small change to add pipeline input
get-officeversion.ps1..txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Habib ZakariaNetwork Solutions ArchitectAuthor Commented:
Hello David,

The list of computers I have should be in text file or CSV? Do I put file in C:\Temp before I run the powershell script.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.