I wanted to find a way to display the Exchange version, build number and which Update Rollup is installed on all servers in the organization. I found the perfect script written by Paul Faherty to do just that. I modified the script slightly to work better in Exchange 2003 / 2007 mixed environments.
Download Get-ExchangeServerVersion.ps1 here: Get-ExchangeServerVersion.zip
When you run it from the Exchange Management Shell prompt you will see output similar to the following screen:
The output displays the server name, Exchange roles installed, version (Standard or Enterprise), version number, and the Update Rollups installed and their installation dates.
For you code monkeys, here's the Powershell code:
#Get-ExchangeServerPlus.ps1
#v1.2, 09/17/2010
#Written By Paul Flaherty, blogs.flaphead.com
#Modified by Jeff Guillet, http://www.expta.com/
#Get a list of Exchange servers in the Org excluding Edge servers
$MsxServers = Get-ExchangeServer | where {$_.ServerRole -ne "Edge"} | sort Name
#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()
write-host $txt1
#Connect to the Server's remote registry and enumerate all subkeys listed under "Patches"
$Srv = $MsxServer.Name
$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\461C2B4266EDEF444B864AD6D9E5B613\Patches\"
$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 2007 patch
$ErrorActionPreference = "SilentlyContinue"
ForEach($sub in $regKey.GetSubKeyNames())
{
Write-Host "- " -nonewline
$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
IF ($Subx -eq "Installed") {
$d = $SUBRegkey.GetValue($SubX)
$d = $d.substring(4,2) + "/" + $d.substring(6,2) + "/" + $d.substring(0,4)
write-Host $d -NoNewLine
}
IF ($Subx -eq "DisplayName") {write-Host ": "$SUBRegkey.GetValue($SubX)}
}
}
write-host ""
}
How about one line of code :-)
ReplyDeletePS > Get-ExchangeServer | Format-List Name,ServerRole,Edition,ExchangeVersion
Thanks, Shay, but that only gives you the Exchange version number.
ReplyDeleteThe code above tells you the Exchange version number, build number, which Update Rollup versions are installed and when they were installed. This is the only way I've found to determine which UR is installed.
Thanks for a great script. I didn't notice the RU info. I ran the script on a VM with no RUs applied.
ReplyDeleteThere is a bug in the installed date string.. should be
ReplyDelete$d = $d.substring(4,2) + "/" + $d.substring(6,2) + "/" + $d.substring(0,4)
(originally there were 2 references to substring(4,2)
Good catch, thanks!
ReplyDeleteWhy do I get this error?
ReplyDeleteThe term 'Get-ExchangeServer' is not recognized as a cmdlet, function, operable
program, or script file. Verify the term and try again.
At C:\Get-ExchangeServerVersion.ps1:8 char:33
...also if you get an error trying to run the script, try using the complete Path and File Name, instead of just the File Name
DeleteAnonymous: Chances are you're running the script from a PowerShell prompt, instead of the Exchange Management Shell. Run the script from EMS and it should work.
ReplyDeleteOk. Just one question.. I don't have any Exchange 2007 in my env. Will the 'Microsoft Exchange Server 2007 Management Tools (32-Bit)' work in my Exch 2003 env?
ReplyDeleteHmmm. It should, but I haven't tried it. If you do, let me know how it goes.
ReplyDeleteThe script works gr8 but how to get the output in CSV file.
ReplyDeleteTo get the script to output to a txt file just add | out-file -filepath c:\FILENAME.txt
ReplyDeleteExchangeVersion returned in not entirely correct. The version returned is "the minimum version of the product that can read the object".
ReplyDeleteCheck out http://blogs.technet.com/b/scottschnoll/archive/2006/12/31/exchange-2007-platforms-and-product-keys.aspx
To get the correct installed version of Exchange, modify line 18 as follows.
ReplyDelete$txt1 = $MsxServer.Name + " [" + $MsxServer.ServerRole + "] [" + $MsxServer.Edition + "] " + $MsxServer.AdminDisplayVersion #$MsxVersion.ExchangeBuild.toString()
Thanks very much, Tim! I've updated the downloadable script and the code above.
ReplyDeleteHi Jeff, I run the script from EMS but I got the following error message;
ReplyDeleteThe term 'Get-ExchangeServerVersion.ps1' is not recognized as a cmdlet, function, operable program,
or script file. Verify the term and try again.
At line:1 char:29
is this blog alive? any hint to Bobby's problem?
ReplyDeleteThis is a common Powershell error if the Powershell environment cannot locate the script your are trying to run. It will also happen if you are not running the script from the Exchange Management Shell.
ReplyDeleteOpen EMS and move to the folder where the script exists to run it.
Great script, thanks you've saved me hours of coding. I modified the reg key as follows to work on Exchange 2010 SP1:
ReplyDeleteHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\AE1D439464EB1B8488741FFA028E291C
Great Script Jeff!
ReplyDeleteThanks. This is a very handy script which makes things easier.
ReplyDeleteThanks for the nice script, his was secure my day ;-)
ReplyDeleteThanks I used it for EX2010
ReplyDeletefor exchange 2010 -
ReplyDeleteGet-ExchangeServer | fl name, admindisplayversion
Nice work i really appreciate that .just tell me how to find the platform for installed exchange server 2007.Of course in production environment each and everyone is preferring for 64 bit platform but i want to ensure that through command .Please tell me the command to find the platform for installed exchange server 2007 in production environment.
ReplyDeleteCreated version that works for Exchange 2007, 2010, and 2013
ReplyDeletePosted here: http://blog.jasonsherry.net/2012/12/27/get-exchangever/
Thanks Jason.
DeleteGet-ExchangeServer -Identity votreserveur | Format-Table Name, AdminDisplayVersion
ReplyDelete(avec votreserveur comme nom du serveur Exchange voulu)
ou dans le cas d’un seul serveur Exchange
Get-ExchangeServer | Format-Table Name, AdminDisplayVersion
La version 14.0 correspond à Exchange 2010
La version 14.1 correspond à Exchange 2010 SP1