{"id":81195,"date":"2016-12-24T00:01:32","date_gmt":"2016-12-24T08:01:32","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=81195"},"modified":"2019-02-18T09:10:17","modified_gmt":"2019-02-18T16:10:17","slug":"curly-blue-and-the-meaning-of-scripting-part-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/curly-blue-and-the-meaning-of-scripting-part-4\/","title":{"rendered":"Curly Blue and the meaning of scripting \u2013 Part 4"},"content":{"rendered":"<p><strong>Summary<\/strong>: Curly Blue learns how to use GitHub resources on PowerShell to clean out old office installations.<\/p>\n<p>When we last saw our hero, Curly Blue, he had been hanging around the office of Azura and discovering the simple ways he could use Windows PowerShell with minimal learning.<\/p>\n<p>In the past few days, he\u2019s seen how easy it is to work and access files by date and time, use features that are built into the Active Directory Administrative Center (ADAC) to identify samples of PowerShell, and pull data by using the Common Information Model (CIM) cmdlets.<\/p>\n<p>He was blinking in disbelief. Although he was a master of using the GUI and keyboard shortcuts and could minimize work in this fashion, the consistency and ease of use of PowerShell was untouchable!<\/p>\n<p>He bade Azura goodbye and continued his tour down the hall with Linux when he encountered two of the deployment specialists, Loopy and Codestock.<\/p>\n<p>Loopy began to dance about frantically with Codestock close at his heels. \u201cDeployment! We need to deploy it now! Aihihighghighighi!!!\u201d<\/p>\n<p>Linux looked over at the pair. \u201cWhat\u2019s the panic about?\u201d<\/p>\n<p>Loopy indicated that as part of the project to migrate the content to the cloud, Office 365 was in scope.\u00a0\u00a0\u00a0 But, as part of the project, they had a double challenge.<\/p>\n<p>\u201cWe need to get the entire network up to Office 2016, but, between our newest acquired division and us, there\u2019s a bad mix of previous Office versions.\u201d Loopy began to fret and shook with worry.<\/p>\n<p>Curly Blue immediate understood the challenge. Every version of Microsoft Office had a similar process for the uninstall, but you needed to target the specific version in the uninstall string. You also needed to know if the previous version was a Click-To-Run edition, which had its own unique process.<\/p>\n<p>Codestock piped up in a squeaky voice \u201cWe\u2019ve found a solution, but it\u2019s manual! If we go to this site on TechNet, there\u2019s a tool that cleans things up beautifully. The challenge is we can\u2019t easily automate it on 5,000 systems!\u201d<\/p>\n<p>Curly looked at the site in question and confirmed the process was manual. At Linux\u2019s suggestion, he did a search for additional tools that involve PowerShell.<\/p>\n<p>\u201cYou\u2019ll probably find a pile of solutions on Github.com and the Powershell Gallery,\u201d he suggested.<\/p>\n<p>He entered the following search on Bing and found a potential tool that might solve his needs.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-122416.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-122416.png\" alt=\"Result of search for \u201cremove previous versions of office github.com\u201d\" width=\"610\" height=\"237\" class=\"alignnone size-full wp-image-81205\" \/><\/a><\/p>\n<p>He was glad Linux had suggested that solution. There appeared to be a prebuilt solution that used both PowerShell and VBScript to do exactly that. With a little more research, Curly managed to vet that the solution was actually part of the Dev.Office.Com Github repository from Microsoft. This boosted his confidence in the solution.<\/p>\n<p>He looked over at Loopy and Codestock, and both were still frantically waving their arms and screaming \u201cPanic! Panic, we must! Panic!\u00a0 Aihighhghih!\u201d<\/p>\n<p>With his new confidence in Windows PowerShell, Curly acquired two test machines, each with unique versions of Microsoft Office. He downloaded the structure from Github to a common share and ran the following lines in PowerShell with administrative rights.<\/p>\n<p style=\"padding-left: 60px\"><code>. .\\Remove-PreviousOfficeInstalls.ps1<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>Remove-PreviousOfficeInstalls -RemoveClickToRunVersions $True -Remove2016Installs $True -KeepUserSettings $True -NoReboot $True<\/code><\/p>\n<p>With no intervention on either machine, each system slowly but surely removed its copy of Microsoft Office.<\/p>\n<p>\u201cBut, but!\u201d shrieked Codestock, \u201cour installer doesn\u2019t <u>run<\/u> in PowerShell!! How do we run this?\u201d<\/p>\n<p>Curly looked over at Linux for a suggestion. \u201cCurly, here\u2019s the part I guess I never mentioned. A PowerShell script or .PS1 file is actually being launched by PowerShell.exe. If you run this in a command prompt with a <code>\/?<\/code>, you can see parameters to pass to it.\u201d<\/p>\n<p>Curly typed it in the Window as Linux suggested and got the following output.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-122416.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-122416.png\" alt=\"Result of powershell.exe \/?\" width=\"663\" height=\"429\" class=\"alignnone size-full wp-image-81215\" \/><\/a><\/p>\n<p>Looking a little further, he found that he could use the following command to start the PowerShell script called RemoveIt.PS1 within a standard CMD script.<\/p>\n<p style=\"padding-left: 60px\"><code>Start \/wait powershell.exe -executionpolicy Bypass -file .\\removeit.ps1<\/code><\/p>\n<p>He passed the solution to Loopy and Codestock who looked at each other and blinked, \u201cWe won\u2019t have to work late tonight! Woohoo!!!!\u201d<\/p>\n<p>Linux looked over at Curly. \u201cNow you\u2019re learning. Not only is PowerShell easy to use, but there are plenty of predefined solutions in the community for you to consume to make your job easier.\u201d<\/p>\n<p>Curly smiled. What a productive morning his first day on the job had been. With only a little bit of PowerShell knowledge, he couldn\u2019t wait to see where this would take him!<\/p>\n<p>Stay tuned for the final episode tomorrow on the Scripting Guys Holiday Special!<\/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 GitHub resources on PowerShell to clean out old office installations. When we last saw our hero, Curly Blue, he had been hanging around the office of Azura and discovering the simple ways he could use Windows PowerShell with minimal learning. In the past few days, he\u2019s seen how [&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-81195","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 GitHub resources on PowerShell to clean out old office installations. When we last saw our hero, Curly Blue, he had been hanging around the office of Azura and discovering the simple ways he could use Windows PowerShell with minimal learning. In the past few days, he\u2019s seen how [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/81195","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=81195"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/81195\/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=81195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=81195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=81195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}