Get Schema version

Just for a change I thought we’d have a look at something different.  The schema is often treated as a big scary thing that we shouldn’t mess with. Many organisations don’t like upgrading the schema.

Lets start by looking at the schema version. This can be easily read but understanding what the version numbers mean is a bit more work

$sch = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySchema]::GetCurrentSchema()            
$de = $sch.GetDirectoryEntry()            
switch ($de.ObjectVersion)            
 13{"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2000"; break}            
 30{"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2003"; break}            
 31{"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2003 R2"; break}            
 44{"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2008"; break}            
 47{"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2008 R2"; break}            
 default{"{0,25} {1,2} " -f "Unknown Schema Version", $($de.ObjectVersion); break}            

Get the current schema using the GetCurrentSchema() method of System.DirectoryServices.ActiveDirectory.ActiveDirectorySchema. Convert it to a directory entry and read the objectversion attribute.

The distinguished name we are working with is CN=Schema,CN=Configuration,DC=Manticore,DC=org so we can use all of our techniques as you’ll see.

This entry was posted in PowerShell and Active Directory. Bookmark the permalink.

One Response to Get Schema version

  1. Hugi says:

    56{“{0,25} ” -f “Schema Version $($de.ObjectVersion) = Windows 2012”; break}
    69{“{0,25} ” -f “Schema Version $($de.ObjectVersion) = Windows 2012 R2”; break}

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s