The estimated reading time 6 minutes

In my daily work I often see lots of different active directory and exchange environments, so I need a short method to determine witch exchange schema version is installed. Also it is important to check the schema version after schema upgrade or Cumulative Update. Yes there are some links you ‘ll find, but every website only checks one specific value like schema version, or objecversion default etc. So I wanted to have this task in one single script which is executable in nearly every environment.
In my test environment there are one DC (Windows Server 2019 Core), one Exchange Server 2019 (core) and one management Server (Windows Server 2019). But also works with older Exchange Server Versions.
Here is the result:

To see this information you need to check some requirements:
1. You need a Windows Server (no client RSAT supported )
2. Execution Policy
because the script is not signed you need to reduce execution policy, I’ll describe later.
3. ActiveDirectory PowerShell Module
If you did not install ActiveDirectory Powershell Module the script can not detect some parameters. So you HAVE TO install it, I’ll describe later
If you say “yeah know these little traps” here is the script.
NOTE : On Exchange Server the AD Powershell Module is installed by default.

>>DOWNLOAD-LINK<<

or you can use powershell to download and store it

$url = "https://blog.it-koehler.com/wp-content/uploads/2019/04/ad-schema-version-exchange-0.1.zip"
$dest = "C:\temp\ad-schema-version-exchange-0.1.zip"
Start-BitsTransfer -Source "$url" -Destination "$dest"

RAW Script

<#
#### requires active directory powershell module on Windows Server####
<#
.SYNOPSIS
shows exchange schema version, objectVersion (Default),objectVersion (Configuration)
https://docs.microsoft.com/en-us/exchange/plan-and-deploy/prepare-ad-and-domains?view=exchserver-2019
.DESCRIPTION

.PARAMETER 
no parameters required
.INPUTS
none
.OUTPUTS

.NOTES
   Version:        0.1
   Author:         Alexander Koehler
   Creation Date:  Thursday, April 11th 2019, 8:25:41 pm
   File: ad-schema-version-exchange-0.1.ps1
   Copyright (c) 2019 blog.it-koehler.com
HISTORY:
Date      	          By	Comments
----------	          ---	----------------------------------------------------------

.LINK
   https://blog.it-koehler.com/en/

.COMPONENT
 Required Modules: ActiveDirectory Powershell (RSAT)

.LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use copy, modify, merge, publish, distribute sublicense and /or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 
.EXAMPLE
change to the directory where script is stored then you can execute it with .\ad-schema-version-exchange-0.1.ps1
#>

#check if Powershell module is installed 
if((Get-WindowsFeature RSAT-AD-PowerShell).Installed){
   
  #get active directory information
  $schemaPath = (Get-ADRootDSE).schemaNamingContext
  #get exchange schema version
  Function Get-ExchangeUpperRange
  {
     Param(
     [parameter(Mandatory=$true)]
     [ValidateNotNullOrEmpty()]
     [Alias("Schemapath")]
     [String[]]
     $RootDSE
   )
  # additional information see https://eightwone.com/references/schema-versions/
  $schemaPath = "$RootDSE"
  $schemaobj = (Get-ADObject -filter * -SearchBase $schemaPath -Properties * | Where-Object {$_.Name -eq "ms-Exch-Schema-Version-Pt"})
  $rangeupper = $schemaobj.rangeUpper
  Write-Output "Exchange Schemaversion: $rangeupper"
  }
  #get exchange object version configuration  
  Function Get-ExchangeObjConf
  {
  $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() 
  $distname = $domain.GetDirectoryEntry().distinguishedName 
  $config = [ADSI]"LDAP://CN=Microsoft Exchange,CN=Services,CN=Configuration,$distname" 
  $orgName = $config.psbase.children | Where-Object {$_.objectClass -eq 'msExchOrganizationContainer'} 
  $ldappath = (($orgName).Path)
  $objconfig = ([ADSI]"$ldappath")
  $objconfigver = $objconfig.objectVersion
  Write-Output "Exchange objectVersion (Configuration): $objconfigver"
  }
    #get exchange object configuration (default )  
  Function Get-ExchangeObjDefaultConf
  {
  $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() 
  $distname = $domain.GetDirectoryEntry().distinguishedName 
  $objdefault = ([ADSI]"LDAP://CN=Microsoft Exchange System Objects,$distname")
  $objdefaultver =$objdefault.objectVersion
  Write-Output "Exchange objectVersion (Default): $objdefaultver"
  }
  Write-Host "### Exchange Active Directory versions ###"
  Get-ExchangeUpperRange -RootDSE "$schemaPath"
  Get-ExchangeObjDefaultConf
  Get-ExchangeObjConf 
  Write-Host " "
  Write-Host "###### additional links:" -ForegroundColor Yellow
  Write-Host "See also this link to check your schema version EX2019: https://docs.microsoft.com/en-us/exchange/plan-and-deploy/prepare-ad-and-domains?view=exchserver-2019#exchange-active-directory-versions" -ForegroundColor Yellow
  Write-Host "See also this link to check your schema version EX2016:https://docs.microsoft.com/en-us/exchange/plan-and-deploy/prepare-ad-and-domains?view=exchserver-2016#exchange-active-directory-versions" -ForegroundColor Yellow
  pause
  
  }
  else{
  
    throw "no active directory powershell module detected please check RSAT Tools 'Get-WindowsFeature RSAT-AD-PowerShell' please install RSAT Tools first on this machine before executing this script
    Import-Module ServerManager
    Add-WindowsFeature -Name 'RSAT-AD-PowerShell' -IncludeAllSubFeature "
  }  

For everyone else who does not know how to setup and what to do; here some quick steps to fulfill the requirements.
Save this script to your server as “.ps1 file” so that it knows its a powershell script

  1. Execution policy preventing powershell running scripts

You’ll get an error executing the script because script is not singed

please disable execution policy only for this task, you need an administrative powershell console
Get-ExecutionPolicy
Set-ExecutionPolicy Unrestricted -Force
Please enable ExecutionPolicy after you’ve done your task!

2. Active Directory PowerShell Module missing

If you see this message, read it! Yes it says there is a feature missing. So you can install it easily via powershell (no restart required, but administrative powershell)

Import-Module ServerManager
Add-WindowsFeature -Name "RSAT-AD-PowerShell" -IncludeAllSubFeature

Rember to enable Execution Policy!

Set-ExecutionPolicy Restricted -Force

If you also want to remove RSAT Tools from this server you can execute the following code to remove AD Module (restart required for complete remove ):

Remove-WindowsFeature -Name "RSAT-AD-PowerShell"

If you liked this article please comment or push the button “helpful”. And if you have any questions do not hesitate to write a comment. I’ll answer them as quickly as possible.

Hope this script helps.
Have fun.

Print Friendly, PDF & Email
  • Was this Helpful ?
  • yes   no