This is an updated version of the script that I wrote for Exchange Server 2007. The new version works for both E2007, E2010 as well as environments where both versions coexist.
Ok, so the script is a bit messy and could use some polish – but, hey, it works for me 🙂
########################################################## # Name: GetExchangeBuild.ps1 # Author: Tony Murray # Version: 2.0 # Date: 22/04/2010 # Comment: PowerShell script to list build info # for each Exchange Server in the organisation # ######################################################### Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -ErrorAction SilentlyContinue Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue $exsrvs = (get-exchangeserver) foreach ($exsrv in $exsrvs) { $version = (get-exchangeserver -identity $exsrv).admindisplayversion $edition = (get-exchangeserver -identity $exsrv).edition write-host “=====================================================” write-host “Exchange Server: $exsrv” write-host $version write-host “Edition: $edition” write-host “Installed Update Rollups:” $baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(’LocalMachine’, $exsrv) $Version8 = "Version 8." If ($version -match $Version8) { $regKey = “SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\ S-1-5-18\Products\461C2B4266EDEF444B864AD6D9E5B613\Patches\” } Else # Version is 14 { $regKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\ S-1-5-18\Products\AE1D439464EB1B8488741FFA028E291C\Patches\" } $baseKey = $baseKey.OpenSubKey($regKey) $Updates = $baseKey.GetSubKeyNames() ForEach($Update in $Updates) { $fullPath= $regKey + $Update $UpdateKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(’LocalMachine’, $exsrv) $UpdateKey = $UpdateKey.OpenSubKey($fullPath) $values = $UpdateKey.GetValueNames() ForEach($value in $values) { if ($value -eq “DisplayName”) {Write-host $UpdateKey.GetValue($value)} } } write-host “=====================================================” }
Watch out for two the lines beginning with $regKey. They might wrap in the window here but should be on one line. Note also that WordPress does something funky with the character codes and you may need to replace the double-quote characters if you copy/paste the code. You can download the file here: getexchangebuildv2ps1.txt