{"id":81085,"date":"2016-12-22T00:01:21","date_gmt":"2016-12-22T08:01:21","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=81085"},"modified":"2019-02-18T09:10:18","modified_gmt":"2019-02-18T16:10:18","slug":"curly-blue-and-the-meaning-of-scripting-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/curly-blue-and-the-meaning-of-scripting-part-2\/","title":{"rendered":"Curly Blue and the meaning of scripting \u2013 Part 2"},"content":{"rendered":"<p><strong>Summary<\/strong>: Curly Blue learns how to use built-in PowerShell script examples in Windows.<\/p>\n<p>Yesterday we met our new friends, Curly Blue and Linux. Curly had started his new job as a IT Professional at Contoso.<\/p>\n<p>The challenge for poor Curly was that he had never learned scripting or, for that matter, gotten into the spirit of it. He had mastered a unique talent of hyper-active data entry skills combined with keyboard shortcuts.<\/p>\n<p>He was now walking to the Office of Azura. She is in charge of managing the migration of the company resources to the cloud. Today she is working with a co-op student, Hermie.<\/p>\n<p>\u201cOur big challenge this week is to identify the location of all the home folders from our user environment in Active Directory,\u201d she says to the young co-op.<\/p>\n<p>Curly overheard this and just tried to picture the task ahead of the young fellow. With over 5,000 users in the environment, he mumbled \u201cOh no\u2026 so many screenshots!\u201d<\/p>\n<p>Azura looked over at Curly. \u201cWhy would you say that? Haven\u2019t you checked out the Active Directory Administrative Center?\u201d<\/p>\n<p>He was quite puzzled. \u201cWhy, yes, it\u2019s one of the new features that was introduced in Windows Server 2008 R2. I find it a far nicer interface to work in. But still, won\u2019t you need screenshots?\u201d<\/p>\n<p>Hermie popped up. \u201cNot really. If I use Windows PowerShell and the Active Directory module, I can do it really quite quickly.\u201d<\/p>\n<p>Again, poor Curly was shaking his head. \u201cOkay, PowerShell again. I get that it does things quickly, but won\u2019t it take time to <u>learn<\/u> how to do this first?\u201d<\/p>\n<p>Azura tapped her chin thoughtfully. \u201cI guess you didn\u2019t notice the big change with the Active Directory Administrative Center that came about in Windows Server 2012?\u201d<\/p>\n<p>Curly was shaking his head in confusion. \u201cWhat \u2018big change\u2019? Cosmetically, the console looks the same.\u00a0 I\u2019m not sure what you\u2019re getting at.\u201d<\/p>\n<p>\u201cCan I show him?\u201d Hermie was so excited \u201cThe first time Azura showed me this trick, I was blown away! I used to say the same thing!\u201d<\/p>\n<p>He opened the with the Active Directory Administrative Center to pull up one of Curly Blue\u2019s users in Active Directory.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-122216.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-122216.png\" alt=\"The Curly Blue account in Active Directory Administrative Center\" width=\"606\" height=\"318\" class=\"alignnone size-full wp-image-81105\" \/><\/a><\/p>\n<p>Curly sat there confused. \u00a0\u201cWhere\u2019s this \u2018really cool\u2019 part?\u201d<\/p>\n<p>Hermie pointed excitedly to the little caret on the far-right lower corner of the Active Directory Administrative Center. \u201cI totally missed this my first 50 times! When Azura showed me this, I fell off the chair!\u201d<\/p>\n<p>He clicked the little icon to the far right side of the words \u201cWINDOWS POWERSHELL HISTORY\u201d<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-122216.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-122216.png\" alt=\"The caret that opens the Windows PowerShell history\" width=\"549\" height=\"44\" class=\"alignnone size-full wp-image-81115\" \/><\/a><\/p>\n<p>Curly nearly dropped his coffee. \u201cIs <em>that<\/em> what I think it is?\u201d glancing at the following screen.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-122216.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-122216.png\" alt=\"Screenshot of the history of commands\" width=\"207\" height=\"249\" class=\"alignnone size-full wp-image-81125\" \/><\/a><\/p>\n<p>Azura confirmed it. \u201cIt most certainly is. Everything that click in the Active Directory Administrative Center is actually a logged PowerShell cmdlet. So, that means that if you do it once in the Active Directory Administrative Center, there is an example of the script that you need to run.\u201d<\/p>\n<p>Hermie nodded. \u201cThis is why, when Azura asked for this report, I already had a copy of the cmdlet that does this stored in my batch of ready-to-use scripts. I can run this one cmdlet to pull down a list of all the users from Active Directory and the key properties we need, which is the HomeFolderPath.\u201d<\/p>\n<p style=\"padding-left: 60px\"><code>Get-ADUser -filter * -properties HomeDirectory -resultsetsize 5000<\/code><\/p>\n<p>Curly glances at a list that populated the length of the screen. He could see within that list the value for the HomeDirectory.<\/p>\n<p>\u201cBut the <u>coolest<\/u> part?\u201d Hermie\u2019s eyes lit up like a 48 port 10 gig switch. \u201cI can make this immediately into a file for Excel!\u201d<\/p>\n<p>He watched as Hermie added in the <strong>Export-CSV<\/strong> cmdlet to the original output.<\/p>\n<p style=\"padding-left: 60px\"><code>Get-ADUser -filter * -properties HomeDirectory -resultsetsize 5000 | Export-CSV HomeDirs.csv<\/code><\/p>\n<p>Curly looked over at Azura. \u201cHow long did it take for him to figure that out?\u201d<\/p>\n<p>She paused thoughtfully. \u201cMaybe the time it took you to ask the question. PowerShell really *is* very easy.\u00a0\u00a0 It\u2019s not like VBScript was or the console apps. It\u2019s <u>very<\/u> consistent in its approach.\u201d<\/p>\n<p>Curly sits there intrigued. For a system that he\u2019d never used before, this PowerShell looked very tempting to get started in.<\/p>\n<p>Visit tomorrow to see how much Curly checks into this new PowerShell universe that is unfolding before his eyes.<\/p>\n<p>I invite you to follow the Scripting Guys on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to them at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. See you tomorrow.<\/p>\n<p>Until then, always remember that with Great PowerShell comes Great Responsibility.<\/p>\n<p><strong>Sean Kearney\n<\/strong>Honorary Scripting Guy\nCloud and Datacenter Management MVP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Curly Blue learns how to use built-in PowerShell script examples in Windows. Yesterday we met our new friends, Curly Blue and Linux. Curly had started his new job as a IT Professional at Contoso. The challenge for poor Curly was that he had never learned scripting or, for that matter, gotten into the spirit [&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":[568,685,641],"tags":[56,154,45],"class_list":["post-81085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-scripting-techniques","category-windows-powershell","tag-guest-blogger","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Curly Blue learns how to use built-in PowerShell script examples in Windows. Yesterday we met our new friends, Curly Blue and Linux. Curly had started his new job as a IT Professional at Contoso. The challenge for poor Curly was that he had never learned scripting or, for that matter, gotten into the spirit [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/81085","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=81085"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/81085\/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=81085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=81085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=81085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}