I first came across this code on Jeff Guillet’s blog here, which the source came from Paul Falherty’s blog initially, back in 2009 for Exchange 2007. Mark E. Smith also had code with a slight modification for Exchange 2010 posted here.
Today I decided to merge these to work with Exchange 2007, 2010, and 2013 into one script.
The change was pretty minor, just had to change the registry path used. Exchange 2010 and 2013 use the same registry path to store updates, but 2007 uses a different one.
# This script will get the Exchange 2007+ version and Update Rollup numbers # Source: http://izzy.org/scripts/Exchange/Admin/Get-ExchangeVer.ps1 # Created by Paul Flaherty, v 1.2 source from Jeff Guillet 9/17/2009 # Orginal source: http://www.expta.com/2009/05/powershell-script-to-get-exchange.html # Modifed by Jason Sherry | Last Updated: 10/22/2012 | Version 1.2 # 05/15/2011 1.1 - Added logging to a file # 12/27/2022 2.0 - Changed code to match latest 1.2 code from Jeff Guillet and added support for Exchange 2010 and 2013 #Get a list of Exchange Server in the Org excluding Edge servers $MsxServers = Get-ExchangeServer | where {$_.ServerRole -ne "Edge"} | sort Name $filename = "MBServerVer-Info.txt" #Loop through each Exchange server that is found ForEach ($MsxServer in $MsxServers) { #Get Exchange server version $MsxVersion = $MsxServer.ExchangeVersion #Create "header" string for output # Servername [Role] [Edition] Version Number $txt1 = $MsxServer.Name + " [" + $MsxServer.ServerRole + "] [" + $MsxServer.Edition + "] " + $MsxServer.AdminDisplayVersion #$MsxVersion.ExchangeBuild.toString() $txt1 | Out-File -FilePath $FileName -Append write-host $txt1 $Version= $MsxServer.AdminDisplayVersion If ($Version -Like "Version 8*") { $key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\461C2B4266EDEF444B864AD6D9E5B613\Patches\" $Version = 2007} If ($Version -Like "Version 14*") { $key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\AE1D439464EB1B8488741FFA028E291C\Patches\" $Version = 2010} If ($Version -Like "Version 15*") { $key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\AE1D439464EB1B8488741FFA028E291C\Patches\" $Version = 2013} #Connect to the Server's remote registry and enumerate all subkeys listed under "Patches" $Srv = $MsxServer.Name $type = [Microsoft.Win32.RegistryHive]::LocalMachine $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv) $regKey = $regKey.OpenSubKey($key) #Loop each of the subkeys (Patches) and gather the Installed date and Displayname of the Exchange patch $ErrorActionPreference = "SilentlyContinue" ForEach($sub in $regKey.GetSubKeyNames()) { $SUBkey = $key + $Sub $SUBregKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv) $SUBregKey = $SUBregKey.OpenSubKey($SUBkey) ForEach($SubX in $SUBRegkey.GetValueNames()) { # Display Installed date and Displayname of the Exchange 2007 patch $Installed = "" IF ($Subx -eq "Installed") { $Installed = $SUBRegkey.GetValue($SubX) $Installed = $Installed.substring(4,2) + "/" + $Installed.substring(6,2) + "/" + $Installed.substring(0,4) } $DisplayName = "" IF ($Subx -eq "DisplayName") { $DisplayName = $SUBRegkey.GetValue($SubX) } If ($Installed -ne "" -And $DisplayName -ne "") { Write-Host "`t$Installed : $DisplayName" "`t$Installed : $DisplayName" | Out-File -FilePath $FileName -Append } } } write-host "" }
Your script has many spaces replaced with which causes PS to error out.
LikeLike
Replaced with
rather. Assuming html tags are allowed in comments maybe it will show properly…
LikeLike
& n b s p ;
LikeLike
Thanks Nick, didn’t notice this but I’ve now fixed it so now HTML codes and formatting should be in the script.
I always post a URL link directly to the latest version of the script on my web server, so go there for the best source code.
LikeLike
I know I’m responding to an old post, but for some reason your script takes much longer to run than the script you modified. Jeff’s script takes but 5-10 seconds to run for my environment, but your script takes 1-2 min. Any ideas why? I can’t spot anything that would cause this.
LikeLike
Nevermind, I have figured it out! In line #53 above, there is a typo. You are missing the $ in front of Installed = “”.
This was causing the script to error out multiple times as it iterates through each subkey value being returned. This was being hidden by the error action being silent.
LikeLike
Oops, thanks! Fixed
LikeLike
Hi, Your script has worked well before, but it fails now to recognize Exchange 2010 SP3 RollUp 10, the last RU for Exchange 2010. SP3 RU10 is Version 14.3 Build 248.2.
This seems to be a common problem I’ve been finding when trying to check the version. The EMC does not report it, it still reports the base SP3 build of 123.4. As does powershell command I’ve used before also fails to report it:
[PS] C:\>Get-ExchangeServer | Format-List Name, Edition, AdminDisplayVersion
Name : EX-CH001
Edition : Standard
AdminDisplayVersion : Version 14.3 (Build 123.4)
I found the command “gcm exsetup | fl” provides the correct build # of the Rolup in the file info of EXSetup.exe:
[PS] C:\>gcm exsetup | fl
Name : ExSetup.exe
CommandType : Application
Definition : D:\Exchange\2010\bin\ExSetup.exe
Extension : .exe
Path : D:\Exchange\2010\bin\ExSetup.exe
FileVersionInfo : File: D:\Exchange\2010\bin\ExSetup.exe
InternalName: ExSetup.exe
OriginalFilename: ExSetup.exe
FileVersion: 14.03.0248.002
FileDescription:
Product: Microsoftr Exchange
ProductVersion: 14.03.0248.002
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: Language Neutral
I also found another script that reports the Rollup 10 as installed at: https://onedrive.live.com/prev?cid=14adc5cf1e0cbccf&id=14ADC5CF1E0CBCCF%21732&v=TextFileEditor
It puts the results in a CSV.
Exchange 2013 CU Build Numbers – http://social.technet.microsoft.com/wiki/contents/articles/15776.exchange-server-2013-and-cumulative-updates-cus-build-numbers.aspx
Exchange Server Update Rollups and Build Numbers – http://social.technet.microsoft.com/wiki/contents/articles/240.exchange-server-and-update-rollups-build-numbers.aspx
Server Name,Rollup Update Description,Installed Date,ExSetup File Version
EX-CH001,No Rollup Updates are installed,,14.03.0123.004
EX-CH002,Update Rollup 10 for Exchange Server 2010 Service Pack 3 (KB3049853) 14.3.248.2,2015/08/29,14.03.0248.002
EX-MB001,No Rollup Updates are installed,,14.03.0123.004
EX-MB002,No Rollup Updates are installed,,14.03.0123.004
Thought I’d pass along what I found so far as it may help someone else in a similar situation. Thanks for your site, it’s been helpful.
LikeLike