Import-Module ActiveDirectory
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False,Position=0)]
[string]
$DomainController
)
if ($DomainController) {
$AD = Get-ADRootDSE -Server $DomainController
Get-ADObject $AD.SchemaNamingContext -Server $DomainController -Property ObjectVersion
} else {
$AD = Get-ADRootDSE
Get-ADObject $AD.SchemaNamingContext -Property ObjectVersion
}
$Forest = $AD.ForestFunctionality
$Domain = $AD.DomainFunctionality
# Use a Here-String to print out the result.
$VersionCodes = @”
Forest: $Forest
Domain: $Domain
Where:
69 = Windows Server 2012 R2
56 = Windows Server 2012
47 = Windows Server 2008 R2
44 = Windows Server 2008
31 = Windows Server 2003 R2
30 = Windows Server 2003
13 = Windows 2000
“@
$VersionCodes