{"id":4212,"date":"2013-02-04T00:01:00","date_gmt":"2013-02-04T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/02\/04\/use-powershell-to-prepare-for-a-domain-upgrade\/"},"modified":"2013-02-04T00:01:00","modified_gmt":"2013-02-04T00:01:00","slug":"use-powershell-to-prepare-for-a-domain-upgrade","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-prepare-for-a-domain-upgrade\/","title":{"rendered":"Use PowerShell to Prepare for a Domain Upgrade"},"content":{"rendered":"<p><strong style=\"font-size: 12px\">Summary:<\/strong><span style=\"font-size: 12px\"> Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to obtain operating system version information from domain controllers.<\/span>\nMicrosoft 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&rsquo;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 &frac12; spoonful of Constant Comment, a spoonful of lemon grass, and a pinch of rose buds, hibiscus flower, and lavender&mdash;I know I got carried away experimenting, but the results are really quite nice). &nbsp;\nI have my Surface&nbsp;RT with me, and I am checking my email. Actually, around our house, the Scripting Wife and I always have our Surface&nbsp;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 <a href=\"http:\/\/www.amazon.com\/gp\/product\/0735676151\/ref=pd_lpo_k2_dp_sr_1\/183-0083590-4076828?pf_rd_m=ATVPDKIKX0DER&amp;pf_rd_s=lpo-top-stripe-1&amp;pf_rd_r=1TD749JD4T4AYK4JSW7P&amp;pf_rd_t=201&amp;pf_rd_p=486539851&amp;pf_rd_i=0735663394\" target=\"_blank\">Windows PowerShell 3.0 First Steps<\/a> 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.<\/p>\n<h2>AD DS domain mode<\/h2>\n<p>Ok, I would like to upgrade my domain functional level to the Windows Server&nbsp;2012 domain functional level, and then I can set the forest functional level to Windows Server&nbsp;2012 as well. I was reading a most excellent TechNet Library article, <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/understanding-active-directory-functional-levels(v=WS.10).aspx\" target=\"_blank\">Understanding Active Directory Domain Services (AD DS) Functional Levels<\/a><em>, <\/em>which explains the different functional levels and enumerates what new features each provides.\nThe 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 <strong>Get-ADDomainMode<\/strong> cmdlet or a <strong>Get-ADForestMode<\/strong> cmdlet. But, hey, I do not really need them, because I can find the domain level and the forest level from the <strong>Get-ADDomain<\/strong> and the <strong>Get-ADForest<\/strong> cmdlets, as shown here.<\/p>\n<p style=\"padding-left: 30px\">14:36 C:&gt; (Get-ADForest).ForestMode<\/p>\n<p style=\"padding-left: 30px\">Windows2008Forest<\/p>\n<p style=\"padding-left: 30px\">14:36 C:&gt; (Get-ADDomain).DomainMode<\/p>\n<p style=\"padding-left: 30px\">Windows2008Domain<\/p>\n<h2>To upgrade the domain and forest functional levels<\/h2>\n<p>To upgrade the domain functional level and the forest functional level to Windows Server&nbsp;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 <strong>Get-ADComputer<\/strong> cmdlet from the ActiveDirectory module to find all of my domain controllers.\nThis is actually rather easy because domain controllers reside in the <strong>Domain Controllers<\/strong> organizational unit (OU) by default (and it is not a good idea to move <strong>Domain Controllers<\/strong> to a different OU without a lot of testing first).\nSo, I know that my domain controllers reside in the <strong>Domain Controllers<\/strong> OU. I can enumerate them by using the <strong>Get-ADComputer<\/strong> cmdlet and specifying the search base.<\/p>\n<p style=\"padding-left: 30px\">Get-ADComputer -SearchBase &#8220;ou=domain controllers,dc=Nwtraders,dc=msft&#8221; -Filter *\nOk, 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.<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=DC3,OU=Domain Controllers,DC=Nwtraders,DC=msft<\/p>\n<p style=\"padding-left: 30px\">DNSHostName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : DC3.Nwtraders.msft<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : DC3<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : computer<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : f65af94d-7d7a-49b7-b7cc-120a0ce5c969<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : DC3$<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-1457956834-3844189528-3541350385-1132<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :\nTo add the OperatingSystem version information, I need to add the <strong>OperatingSystem<\/strong> attribute to the <strong>&ndash;properties<\/strong><em> <\/em>parameter. The revised command is shown here.<\/p>\n<p style=\"padding-left: 30px\">Get-ADComputer -SearchBase &#8220;ou=domain controllers,dc=iammred,dc=net&#8221; -Filter * -Properties operatingsystem\nI can now create a table of the required information by piping the output to the <strong>Format-Table<\/strong> cmdlet, as shown here.<\/p>\n<p style=\"padding-left: 30px\">15:23 C:&gt; Get-ADComputer -SearchBase &#8220;ou=domain controllers,dc=iammred,dc=net&#8221; -Filter * -Properties operatingsystem | Format-Table name, operatingsystem -auto<\/p>\n<p style=\"padding-left: 30px\">name operatingsystem<\/p>\n<p style=\"padding-left: 30px\">&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p style=\"padding-left: 30px\">DC4&nbsp; Windows Server 2012 Standard<\/p>\n<p style=\"padding-left: 30px\">DC2&nbsp; Windows Server 2012 Standard<\/p>\n<p style=\"padding-left: 30px\">DC1&nbsp; Windows Server&reg; 2008 Enterprise without Hyper-V<\/p>\n<p style=\"padding-left: 30px\">DC3&nbsp; Windows Server 2012 Standard\nOk, 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.<\/p>\n<p style=\"padding-left: 30px\">15:23 C:&gt; Get-ADComputer -SearchBase &#8220;ou=domain controllers,dc=iammred,dc=net&#8221; -Filter * -Properties operatingsystem | Sort-Object operatingsystem | Format-Table name, operatingsystem -auto<\/p>\n<p style=\"padding-left: 30px\">name operatingsystem<\/p>\n<p style=\"padding-left: 30px\">&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p style=\"padding-left: 30px\">DC3&nbsp; Windows Server 2012 Standard<\/p>\n<p style=\"padding-left: 30px\">DC2&nbsp; Windows Server 2012 Standard<\/p>\n<p style=\"padding-left: 30px\">DC4&nbsp; Windows Server 2012 Standard<\/p>\n<p style=\"padding-left: 30px\">DC1&nbsp; Windows Server&reg; 2008 Enterprise without Hyper-V\nJoin me tomorrow when I will talk about more cool Windows PowerShell stuff.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,46,3,8,45],"class_list":["post-4212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-computer-accounts","tag-scripting-guy","tag-searching-active-directory","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4212"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4212\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}