0

Get Exchange Schema Version Using Powershell

If it has been a while since your last Microsoft Exchange Server install or if you inherited a setup, you might be wondering what’s the easiest and quickest way to get Exchange schema version. Lucky for you, we’re in the business of making things as quick and easy as possible for you. Today we’re going to go over the steps to check the schema version using Powershell.

Requirements

  • The ActiveDirectory Powershell Module must be installed on the machine running the script
  • Exchange Server Installed in your Domain

 
In order for things to run smoothly, we’ll need to make sure the machine running the script has the ActiveDirectory module installed. Aside from that, there are no specific permissions needed since this is available as read-only attributes to anyone in the domain. One caveat is that this has only been tested on Domains that have an Exchange Server installed so I’m sure it will error out if it doesn’t find the attributes it needs.

Get Exchange Schema Version Using Powershell

Here is the quick and easy way for finding exactly which Exchange Schema version you’re running in your environment.
 


Function Get-ExchangeSchemaVersion {
#requires -Module ActiveDirectory
<#
.SYNOPSIS
    This script check your current Exchange Schema Version.

.DESCRIPTION
    Microsoft Link for Exchange Server Versions
    https://docs.microsoft.com/en-us/exchange/plan-and-deploy/prepare-ad-and-domains?view=exchserver-2016#exchange-active-directory-versions
    https://docs.microsoft.com/en-us/exchange/plan-and-deploy/prepare-ad-and-domains?view=exchserver-2019#exchange-active-directory-versions

.NOTES
    Name: Get-ExchangeSchemaVersion
    Author: theSysadminChannel
    Version: 1.0
    LastUpdated: 2021-Nov-9

.LINK
    https://thesysadminchannel.com/get-exchange-schema-version-using-powershell -

.EXAMPLE
    Get-ExchangeSchemaVersion
#>

    [CmdletBinding()]
    param(
        #No Parameters needed in this case.
    )

    BEGIN {
        #Only 2016 and 2019 Version Are Supported to Display Exchange CU Version. 
        $ExchangeVersion = @{
            44798 = 'Exchange 2016 CU22'
            44796 = 'Exchange 2016 CU21'
            44793 = 'Exchange 2016 CU20'
            44791 = 'Exchange 2016 CU19'
            44788 = 'Exchange 2016 CU18'
            44786 = 'Exchange 2016 CU17'
            44783 = 'Exchange 2016 CU12'
            44782 = 'Exchange 2016 CU11'
            44781 = 'Exchange 2016 CU10'
            44779 = 'Exchange 2016 CU6'
            44775 = 'Exchange 2016 CU5'
            44774 = 'Exchange 2016 CU3'
            44773 = 'Exchange 2016 CU2'
            44770 = 'Exchange 2016 CU1'
            44763 = 'Exchange 2016 RTM'
            44594 = 'Exchange 2016 Preview'
            #
            47004 = 'Exchange 2019 CU11'
            47002 = 'Exchange 2019 CU10'
            46999 = 'Exchange 2019 CU9'
            46997 = 'Exchange 2019 CU8'
            46994 = 'Exchange 2019 CU7'
            46992 = 'Exchange 2019 CU6'
            46988 = 'Exchange 2019 CU1'
            46987 = 'Exchange 2019 RTM'

        }
    }

    PROCESS {
        try {
            $DomainController = Get-ADDomain | select -ExpandProperty PDCEmulator
            $ADRootDSE = Get-ADRootDSE -Server $Domaincontroller -ErrorAction Stop

            $UpperObject = "CN=ms-Exch-Schema-Version-Pt,"+$ADRootDSE.SchemaNamingContext
            $RangeUpper = Get-ADObject $UpperObject -Properties RangeUpper | select -ExpandProperty RangeUpper


            $NamingContext = "CN=Microsoft Exchange System Objects," + $ADRootDSE.DefaultNamingContext
            $ObjectVersion_Default = Get-ADObject $NamingContext -Properties ObjectVersion | select -ExpandProperty ObjectVersion

            $ConfigContext = $ADRootDSE.ConfigurationNamingContext
            $ObjectVersion_Configuration = Get-ADObject -LDAPFilter "(objectClass=msExchOrganizationContainer)" -SearchBase $ConfigContext -Properties ObjectVersion | select -ExpandProperty ObjectVersion

            [PSCustomObject]@{
                ExchangeVersion             = $ExchangeVersion[$RangeUpper + $ObjectVersion_Default + $ObjectVersion_Configuration]
                RangeUpper                  = $RangeUpper
                ObjectVersion_Default       = $ObjectVersion_Default
                ObjectVersion_Configuration = $ObjectVersion_Configuration
            }

        } catch {
            Write-Error $_.Exception.Message
        }
    }

    END {}
}

 
Get Exchange Schema Version Powershell

How to Confirm Exchange Version

Once you’ve determined the schema, you can also cross check with the Exchange Version that’s currently installed in your environment. I wrote another script to get Exchange Cumulative Update Version and Build Numbers Using Powershell so this will also be useful to determine the footprint. When I connect to my Exchange Server and run that function, I am showing as having “Exchange Server 2019 Cumulative Update 1 (CU1)” installed which coincides with my schema version.

Get Exchange Version Powershell

Conclusion

Hopefully this article was able to relay how to get Exchange Schema Version Using Powershell in your environment. If you liked this article, be sure to check out our other Powershell Posts as well as our Exchange Server category items.

5/5 - (8 votes)

Paul Contreras

Hi, my name is Paul and I am a Sysadmin who enjoys working on various technologies from Microsoft, VMWare, Cisco and many others. Join me as I document my trials and tribulations of the daily grind of System Administration.

Leave a Reply

Your email address will not be published. Required fields are marked *