Skip to main content

Displaying what version of Exchange your using (Enterprise or Standard) via Script

Somebody asked me this question this week and what I thought would be quite easy turned out to be a little hard. On a Exchange 2003 box there is a WMI class Exchange_Server that you can use to do this and there is a sample in the Exchange SDK here.

But this WMI class isn’t available in Exchange 2000, The PSS knowledge base offers two solutions one is based on looking for event id 1217 or 1216 in the event log and the other one is to use the Guid from the Uninstall key in the registry and they supply all the Guid's for Exchange 2000 Q296587. Unfortunately there didn’t seem to be the same information available for Exchange 2003. A check of the ExBPA which seems to be using the same method did yield all the GUID'S for Exchange 2003 as well as the SBS versions. The Exbpa actually makes quite a good scripting reference if you have a look at the “ExBPA.Config.xml” config file there’s quite a lot of good information about how they are going about retrieving various pieces of information used in this tool.

So putting this together in a script meant using the StdRegProv WMI class to connect to the registry of each server then going though the keys of the uninstall tree looking for the GUID. I combined this will a little code that queried for all the exchange servers in a domain and also grabbed the serialnumber AD property which contains the Build number and service pack of the Exchange server .And the result is the following script that will show which version of Exchange you are using (Standard, Enterprise, SBS or Eval) and what build number and service pack each server is running. I’ve posted a download copy of the script here

The code looks like

set conn = createobject("ADODB.Connection")
set com = createobject("ADODB.Command")
Set iAdRootDSE = GetObject("LDAP://RootDSE")
strNameingContext = iAdRootDSE.Get("configurationNamingContext")
Conn.Provider = "ADsDSOObject"
Conn.Open "ADs Provider"
svcQuery = "<LDAP://" & strNameingContext & ">;(objectCategory=msExchExchangeServer);name,serialNumber,distinguishedName;subtree"
Com.ActiveConnection = Conn
Com.CommandText = svcQuery
Set Rs = Com.Execute
Wscript.echo "Exchange Servers Versions"
Wscript.echo
While Not Rs.EOF
arrSerial = rs.Fields("serialNumber")
For Each Serial In arrSerial
strexserial = Serial
Next
ExVersion = getExversion(rs.fields("name"))
wscript.echo rs.fields("name") & " " & ExVersion & " " & strexserial
Rs.MoveNext
Wend
Rs.Close
Conn.Close
Set Rs = Nothing
Set Com = Nothing
Set Conn = Nothing

function getExversion(strComputer)
const HKEY_LOCAL_MACHINE = &H80000002
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
select case ucase(subkey)
case ucase("DB20F7FD-67BC-4813-8808-78F63E89EB56") ExVersion = "Exchange 2000 Standard"
case ucase("775CF3DA-C007-4709-B4CC-CE2239BE2E03") Exversion = "Exchange 2000 Standard"
case ucase("FC6FA539-452D-4a9b-8065-C1FA74B86F83") ExVersion = "Exchange 2000 Standard Evaluation"
case ucase("D3574E0C-360A-44d5-858C-33323C2D79F2") ExVersion = "Exchange 2000 Enterprise"
case ucase("F8567801-906B-439b-8D6A-87BDFEC9BA52") ExVersion = "Exchange 2000 Enterprise"
case ucase("65D9643D-06E8-47d6-865E-80F4CC9BB879") ExVersion = "Exchange 2000 Enterprise"
case ucase("8B102332-6052-4af3-ADFA-35A3DED0506A") ExVersion = "Exchange 2000 Enterprise Evaluation"
case ucase("ee2d3727-33c0-11d2-ab50-00c04fb1799f") ExVersion = "Exchange 2000 Standard SBS"
case ucase("EAE76D62-2691-4883-8BBB-1F2EE6D370D5") ExVersion = "Exchange 2003 Standard"
case ucase("9682A75B-EBD1-4c7d-88F9-13BE236F706C") ExVersion = "Exchange 2003 Standard"
case ucase("9161A261-6ABE-4668-BBFA-AD06B3F642CF") ExVersion = "Exchange 2003 Standard"
case ucase("D8862944-4F8A-429d-9A4F-6F201428FB0C") ExVersion = "Exchange 2003 Standard Evaluation"
case ucase("C160866F-DE53-434f-ADF1-CC42ABBF8778") ExVersion = "Exchange 2003 Standard Evaluation"
case ucase("74F3BB3C-A434-48fa-AAC1-3FC37CD2B0DB") ExVersion = "Exchange 2003 Enterprise"
case ucase("7F4210A8-D3B4-480a-835E-D5DAA0D0B157") ExVersion = "Exchange 2003 Enterprise"
case ucase("4050D45F-9598-44bc-8C07-4C1BBE22EFBB") ExVersion = "Exchange 2003 Enterprise"
case ucase("F95DE19F-CF69-4b03-81B6-9EC050D20D3B") ExVersion = "Exchange 2003 Enterprise"
case ucase("3D5A0E1C-B6DA-42a7-A871-03CD2E30FEA3") ExVersion = "Exchange 2003 Enterprise Evaluation"
case ucase("2B8EC4BD-5638-47e2-8817-1A50B38A828D") ExVersion = "Exchange 2003 Enterprise Evaluation"
case ucase("5717D53E-DD6D-4d1e-8A1F-C7BE620F65AA") ExVersion = "Exchange 2003 Standard SBS"
end select
Next
getExversion = ExVersion
end function

Popular posts from this blog

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Sending a MimeMessage via the Microsoft Graph using the Graph SDK, MimeKit and MSAL

One of the new features added to the Microsoft Graph recently was the ability to create and send Mime Messages (you have been able to get Message as Mime for a while). This is useful in a number of different scenarios especially when trying to create a Message with inline Images which has historically been hard to do with both the Graph and EWS (if you don't use MIME). It also opens up using SMIME for encryption and a more easy migration path for sending using SMTP in some apps. MimeKit is a great open source library for parsing and creating MIME messages so it offers a really easy solution for tackling this issue. The current documentation on Send message via MIME lacks any real sample so I've put together a quick console app that use MSAL, MIME kit and the Graph SDK to send a Message via MIME. As the current Graph SDK also doesn't support sending via MIME either there is a workaround for this in the future my guess is this will be supported.

Export calendar Items to a CSV file using Microsoft Graph and Powershell

For the last couple of years the most constantly popular post by number of views on this blog has been  Export calendar Items to a CSV file using EWS and Powershell closely followed by the contact exports scripts. It goes to show this is just a perennial issue that exists around Mail servers, I think the first VBS script I wrote to do this type of thing was late 90's against Exchange 5.5 using cdo 1.2. Now it's 2020 and if your running Office365 you should really be using the Microsoft Graph API to do this. So what I've done is create a PowerShell Module (and I made it a one file script for those that are more comfortable with that format) that's a port of the EWS script above that is so popular. This script uses the ADAL library for Modern Authentication (which if you grab the library from the PowerShell gallery will come down with the module). Most EWS properties map one to one with the Graph and the Graph actually provides better information on recurrences then...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.