February 24, 2023

Check Microsoft Exchange Schema Version

# Exchange Schema Version

$sc = (Get-ADRootDSE).SchemaNamingContext

$ob = "CN=ms-Exch-Schema-Version-Pt," + $sc

Write-Output "RangeUpper: $((Get-ADObject $ob -pr rangeUpper).rangeUpper)" # Exchange Object Version (domain)

$dc = (Get-ADRootDSE).DefaultNamingContext

$ob = "CN=Microsoft Exchange System Objects," + $dc

Write-Output "ObjectVersion (Default): $((Get-ADObject $ob -pr objectVersion).objectVersion)" # Exchange Object Version (forest)

$cc = (Get-ADRootDSE).ConfigurationNamingContext

$fl = "(objectClass=msExchOrganizationContainer)"

Write-Output "ObjectVersion (Configuration): $((Get-ADObject -LDAPFilter $fl -SearchBase $cc -pr objectVersion).objectVersion)" # Exchange Object Version (configuration)


This script will give you the output in below format:

Post Schema Update :
RangeUpper: 15334
ObjectVersion (Default): 13243
ObjectVersion (Configuration): 16223

February 19, 2023

Get SID of Active Directory Forest

$rootDomainSid = (Get-ADDomain -Server (Get-ADForest).RootDomain).DomainSID.value

$hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')

$hash = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($rootDomainSid))

$hashString = [System.BitConverter]::ToString($hash)

$hashString.Replace('-', '')