Solved

Powershell Script to get Outlook/Office Version and Service Pack Info on Our Domain

Posted on 2012-04-10
8
6,736 Views
Last Modified: 2013-02-28
Hi  ,

I want to write a powershell script to know the MS Office Version and Service Pack Info on the desktop machine . We have about 4000 machines on our network.

The current script gives me only the version number :


foreach ($computer in (Get-Content ipaddress.txt)) {
  foreach ($computer ) {
  $version = 0
  $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) {
      "$computer : found $version"
    }
    else {
      "Could not find version for $computer"
  }
}


Any ideas ?
0
Comment
Question by:MOITExperts
[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
8 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37828136
service pack information is in the version number... you have to detect which version means what.... see below for details of sp1 changes to version

http://support.microsoft.com/kb/928116/
0
 

Author Comment

by:MOITExperts
ID: 37828174
Yep you are right but the issue i am having with the script above is i just get version numbers as 12,14,13 etc .

And that does not help me in finding the service pack info.

I am just doing a match using the registry and check the version ... i am not able to find the service pack info

Thanks
-Shreyas
0
 
LVL 6

Expert Comment

by:slidingfox
ID: 37828321
foreach ($computer in (Get-Content ipaddress.txt)) {

    $officever = ''
    $officesp = ''

    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot', $computer)

    $reg = $reg.OpenSubKey('Word.Application\CurVer').GetValue('')
     
    if ($reg.EndsWith(11)) {
     
        $officever = 'Office 2003'
        $sp = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Office\11.0\Common\ProductVersion).LastProduct

        if ($sp -like '11.0.8*') {
            $officesp = 'Service Pack 3'
        } elseif ($sp -like '11.0.7*') {
            $officesp = 'Service Pack 2'
        } elseif ($sp -like '11.0.6*') {
            $officesp = 'Service Pack 1'
        } else {
            $officesp = 'No Service Pack'
        }        
       
     
    } elseif ($reg.EndsWith(12)) {
       
        $officever = 'Office 2007'
        $sp = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Office\12.0\Common\ProductVersion).LastProduct
       
        if ($sp -like '12.0.66*') {
            $officesp = 'Service Pack 3'
        } elseif ($sp -like '12.0.64*') {
            $officesp = 'Service Pack 2'
        } elseif ($sp -like '12.0.62*') {
            $officesp = 'Service Pack 1'
        } else {
            $officesp = 'No Service Pack'
        }
     
    } elseif ($reg.EndsWith(14)) {
   
        $officever = "Office 2010"
        $sp = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Office\14.0\Common\ProductVersion).LastProduct
     
        if ($sp -like '14.0.60*') {
            $officesp = 'Service Pack 1'
        } else {
            $officesp = 'No Service Pack'
        }  
     
    }
   
Write-Output "$officever $officesp"
     
}
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

 
LVL 6

Expert Comment

by:slidingfox
ID: 37828451
Apologies, forgot to add the computername to the output. Replace the Write-Output line with

"$computer - $officever $officesp"
0
 

Author Comment

by:MOITExperts
ID: 37829032
Thank you for the script but this again helps me in retrieving the version but when i go through the loop where it checks for service pack i get an error

Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Common\ProductVersion' because it does not ex
ist.
+  $sp = (Get-ItemProperty <<<<  HKLM:\SOFTWARE\Microsoft\Office\14.0\Common\ProductVersion).LastProduct
    + CategoryInfo          : ObjectNotFound: (HKLM:\SOFTWARE\...\ProductVersion:String) [Get-ItemProperty], ItemNotFo
   undException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand

So i did open the registry and i did try to find the "Productversion" under /software/microsoft/common/

There was no file and hence it was not able to compare the string so everytime i get this error and output is returned as "Office 200x No Service Pack found "

Once Again Thank you for your help !!!
0
 
LVL 3

Accepted Solution

by:
ericwoodford earned 500 total points
ID: 38046629
get-logonstatistics "mailbox"  | select  UserName, Clientversion 

Open in new window


Will tell what client version that they just logged on to their mailbox with.

Username  ClientVersion
Eric W             14.0.6109.5000

You can search Technet to get exactly what patch/hotfix this relates to.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

738 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