{"id":80405,"date":"2016-11-04T00:01:28","date_gmt":"2016-11-04T07:01:28","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=80405"},"modified":"2019-02-18T09:10:23","modified_gmt":"2019-02-18T16:10:23","slug":"open-source-powershell-part-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/open-source-powershell-part-1\/","title":{"rendered":"Open Source PowerShell \u2013 Part 1"},"content":{"rendered":"<p><strong>Summary<\/strong>: Find and install the Open Source PowerShell software for Linux or Windows.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/> I was reading up about a great new change in PowerShell. I heard that the newest version was Open Sourced on GitHub. Any chance you could give me a quick run-through to check it out?<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/> Honorary Scripting Guy, Sean Kearney, is here today to bring you up to pace with the coolest new change that was introduced ever. The newest version of Windows PowerShell (version 6.0) is on GitHub.com as an Open Source project!<\/p>\n<p>Don\u2019t believe me? Check it out right now at <a target=\"_blank\" href=\"https:\/\/github.com\/PowerShell\/PowerShell\">https:\/\/github.com\/PowerShell\/PowerShell<\/a>.<\/p>\n<p>To say, \u201cThis is big,\u201d is a very large understatement. It\u2019s <u>groundbreaking<\/u> in what it brings forth. First off, consider the list of supported platforms in the current alpha release.<\/p>\n<ul>\n<li>Windows 10 \/ Server 2016<\/li>\n<li>Windows 8.1 \/ Server 2012 R2<\/li>\n<li>Ubuntu 16.04<\/li>\n<li>Ubuntu 14.04<\/li>\n<li>CentOS 7<\/li>\n<li>macOS 10.11<\/li>\n<li>Docker<\/li>\n<\/ul>\n<p>A supported cross-platform version of PowerShell is not just cool for Microsoft admins either. Just think of the possibilities. Unix admins can finally (after, of course, it eventually is RTM, naturally) take advantage of running Windows PowerShell scripts remotely.<\/p>\n<p>This will allow them not only to capture the output of a Windows session but also the <u>status<\/u> code of the run script.<\/p>\n<p>It also provides some of the amazing features that we in the PC world have long enjoyed about PowerShell, the consistent structure of the cmdlets and Help system. But, more importantly, PowerShell brings to the table the ability to easily convert various data types like JSON and consume them as objects.<\/p>\n<p>Cmdlets, like <code>ConvertFrom-String<\/code>, can now take raw string output in a Linux environment and turn that into easily manipulatable objects.<\/p>\n<p>Possibly the <u>biggest<\/u> piece is how PowerShell integrates into these environments. It does it on the environment\u2019s terms. It\u2019s just another Shell! It uses the same package installation process as any other Unix solution.<\/p>\n<p>It also should be pointed out that Open Source PowerShell fully respects the <a href=\"https:\/\/specifications.freedesktop.org\/basedir-spec\/basedir-spec-latest.html\">XDG Base Directory Specification<\/a> on Linux and macOS. This means something as simple as, \u201cPowerShell sits in the proper folders on these systems, not \u2018\/Program Files\/\u2019\u201d.<\/p>\n<p>Now the fun part. Getting your hands on it.<\/p>\n<p>The simplest method is really to just grab the install.sh script for Unix systems. This script will determine the parent *nix operating system and grab the appropriate package. It will also bring down any required dependencies that correspond to the version of Linux or macOS you\u2019re running.<\/p>\n<p>Just execute the following line to download the script.<\/p>\n<p style=\"padding-left: 60px\"><code>wget https:\/\/raw.githubusercontent.com\/PowerShell\/PowerShell\/v6.0.0-alpha.10\/tools\/download.sh<\/code><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-110416.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-110416.png\" alt=\"Download the script\" width=\"663\" height=\"111\" class=\"alignnone size-full wp-image-80415\" \/><\/a><\/p>\n<p>After you have downloaded the file, you\u2019ll need to make it an executable script by using chmod. You\u2019ll be prompted for your credentials to elevate this in Linux and macOS.<\/p>\n<p style=\"padding-left: 60px\"><code>sudo chmod +x download.sh<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>sudo .\/download.sh<\/code><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-110416.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-110416.png\" alt=\"Use chmod to create an executable\" width=\"577\" height=\"251\" class=\"alignnone size-full wp-image-80425\" \/><\/a><\/p>\n<p>At this point, it will now download the binaries and begin to install them. After it\u2019s done, you\u2019ll be able to run PowerShell as you would in the PC world (except powershell is in all lowercase). Remember Linux and macOS are case-sensitive.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-110416.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-110416.png\" alt=\"Screenshot of PowerShell running on Linux\" width=\"654\" height=\"448\" class=\"alignnone size-full wp-image-80435\" \/><\/a><\/p>\n<p>Now, if you like, you can even download the pkg or deb file (depending on your destination environment) and install it in the same normal manner as any other package in Linux or macOS.<\/p>\n<p>It <u>also<\/u> means removal of PowerShell is <u>exactly<\/u> how you would expect it to be. It uses the solution that\u2019s native to the environment.<\/p>\n<p><strong>For CentOS 7<\/strong><\/p>\n<p style=\"padding-left: 60px\"><code>sudo yum remove powershell<\/code><\/p>\n<p><strong>For Ubuntu 14\/16<\/strong><\/p>\n<p style=\"padding-left: 60px\"><code>sudo apt-get remove powershell<\/code><\/p>\n<p>Now, keep in mind this is Alpha software. It\u2019s in development. It should do things that you don\u2019t expect it to. This is <u>not<\/u> meant for a production system. But, it\u2019s great to get your hands on it and get a feel for it.<\/p>\n<p>Also, because this is an Open Source solution on GitHub, you can get your feedback <u>directly<\/u> to the team that\u2019 developing it and contribute to its improvement.<\/p>\n<p>Stop by next week, and I\u2019ll go into how you can use it interactively with the Linux and macOS environments, just like you can with Bash or Python (or any other shell you presently have).<\/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: Find and install the Open Source PowerShell software for Linux or Windows. I was reading up about a great new change in PowerShell. I heard that the newest version was Open Sourced on GitHub. Any chance you could give me a quick run-through to check it out? Honorary Scripting Guy, Sean Kearney, is here [&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,641],"tags":[56,154,45],"class_list":["post-80405","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-windows-powershell","tag-guest-blogger","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Find and install the Open Source PowerShell software for Linux or Windows. I was reading up about a great new change in PowerShell. I heard that the newest version was Open Sourced on GitHub. Any chance you could give me a quick run-through to check it out? Honorary Scripting Guy, Sean Kearney, is here [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80405","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=80405"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80405\/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=80405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=80405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=80405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}