# Här är ett litet PS script som frågar alla DC's i Forest efter vilken schemaversion den kör.

$dclist = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ } | Select-Object -ExpandProperty hostname

foreach ( $dc in $dclist ) {

    $schemaversion = Get-ADObject -Server $dc (Get-ADRootDSE).schemaNamingContext -Property objectVersion | Select-Object -ExpandProperty objectversion

    if ($schemaversion -eq 13){ $schemaversiontxt = "Windows 2000"}

    if ($schemaversion -eq 30){ $schemaversiontxt = "Windows Server 2003"}

    if ($schemaversion -eq 31){ $schemaversiontxt = "Windows Server 2003 R2"}

    if ($schemaversion -eq 44){ $schemaversiontxt = "Windows Server 2008"}

    if ($schemaversion -eq 47){ $schemaversiontxt = "Windows Server 2008 R2"}

    if ($schemaversion -eq 56){ $schemaversiontxt = "Windows Server 2012"}

    if ($schemaversion -eq 69){ $schemaversiontxt = "Windows Server 2012 R2"}

    Write-Output "$dc`t: $schemaversion`t: $schemaversiontxt"

}