Use PowerShell to Prepare for a Domain Upgrade

Use PowerShell to Prepare for a Domain Upgrade

  • Comments 2
  • Likes

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to obtain operating system version information from domain controllers.

Microsoft Scripting Guy, Ed Wilson, is here. The weather in Charlotte, North Carolina, has been a bit strange of late. There were tornados in Georgia recently, and the temperatures around here rose to 70 degrees Fahrenheit (21 degrees Celsius). It was so warm, the Scripting Wife and I opened the windows and turned off the heat. Well, today, it’s like 35 degrees Fahrenheit (1.6 degrees Celsius), and I do not have the windows open. But I am sitting on the lanai, sipping a nice cup of hot tea (Darjeeling with a spoonful of green tea, a ½ spoonful of Constant Comment, a spoonful of lemon grass, and a pinch of rose buds, hibiscus flower, and lavender—I know I got carried away experimenting, but the results are really quite nice).  

I have my Surface RT with me, and I am checking my email. Actually, around our house, the Scripting Wife and I always have our Surface RTs with us. They follow us up and down the stairs like forlorn puppies as they constantly clamor for attention. Because the Scripting Manager gave me today off, I am being rather mellow this morning. I will probably finish writing my new Microsoft Press Windows PowerShell 3.0 First Steps book, and then take the Scripting Wife out for lunch and a movie. Seems like a cool thing to do, and we have not seen a movie in a while.

AD DS domain mode

Ok, I would like to upgrade my domain functional level to the Windows Server 2012 domain functional level, and then I can set the forest functional level to Windows Server 2012 as well. I was reading a most excellent TechNet Library article, Understanding Active Directory Domain Services (AD DS) Functional Levels, which explains the different functional levels and enumerates what new features each provides.

The first thing I need to do is to find out the functional level of both the forest and the domain. Unfortunately, there is not a Get-ADDomainMode cmdlet or a Get-ADForestMode cmdlet. But, hey, I do not really need them, because I can find the domain level and the forest level from the Get-ADDomain and the Get-ADForest cmdlets, as shown here.

14:36 C:\> (Get-ADForest).ForestMode

Windows2008Forest

14:36 C:\> (Get-ADDomain).DomainMode

Windows2008Domain

To upgrade the domain and forest functional levels

To upgrade the domain functional level and the forest functional level to Windows Server 2012, I need to upgrade all of my domain controllers to Windows Server 2012. To do that, I need to first see where my domain controllers reside, and what version of the operating system they run. I can use the Get-ADComputer cmdlet from the ActiveDirectory module to find all of my domain controllers.

This is actually rather easy because domain controllers reside in the Domain Controllers organizational unit (OU) by default (and it is not a good idea to move Domain Controllers to a different OU without a lot of testing first).

So, I know that my domain controllers reside in the Domain Controllers OU. I can enumerate them by using the Get-ADComputer cmdlet and specifying the search base.

Get-ADComputer -SearchBase "ou=domain controllers,dc=Nwtraders,dc=msft" -Filter *

Ok, that is a good start. But, the output does not include the OperatingSystem information. A sample of the type of information returned is shown here.

DistinguishedName : CN=DC3,OU=Domain Controllers,DC=Nwtraders,DC=msft

DNSHostName       : DC3.Nwtraders.msft

Enabled           : True

Name              : DC3

ObjectClass       : computer

ObjectGUID        : f65af94d-7d7a-49b7-b7cc-120a0ce5c969

SamAccountName    : DC3$

SID               : S-1-5-21-1457956834-3844189528-3541350385-1132

UserPrincipalName :

To add the OperatingSystem version information, I need to add the OperatingSystem attribute to the –properties parameter. The revised command is shown here.

Get-ADComputer -SearchBase "ou=domain controllers,dc=iammred,dc=net" -Filter * -Properties operatingsystem

I can now create a table of the required information by piping the output to the Format-Table cmdlet, as shown here.

15:23 C:\> Get-ADComputer -SearchBase "ou=domain controllers,dc=iammred,dc=net" -Filter * -Properties operatingsystem | Format-Table name, operatingsystem -auto

name operatingsystem

---- ---------------

DC4  Windows Server 2012 Standard

DC2  Windows Server 2012 Standard

DC1  Windows Server® 2008 Enterprise without Hyper-V

DC3  Windows Server 2012 Standard

Ok, that is a bit better, but the operating systems are all jumbled up, and I am particularly interested in the Windows Server 2008 R2 and earlier computers. So, I will sort the output prior to creating the table. Here is the revision.

15:23 C:\> Get-ADComputer -SearchBase "ou=domain controllers,dc=iammred,dc=net" -Filter * -Properties operatingsystem | Sort-Object operatingsystem | Format-Table name, operatingsystem -auto

name operatingsystem

---- ---------------

DC3  Windows Server 2012 Standard

DC2  Windows Server 2012 Standard

DC4  Windows Server 2012 Standard

DC1  Windows Server® 2008 Enterprise without Hyper-V

Join me tomorrow when I will talk about more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Informative. Thank you.

  • @Srinu Tamada Thank you, I am glad you found the article informative.