{"id":32966,"date":"2020-11-14T16:09:01","date_gmt":"2020-11-14T16:09:01","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=32966"},"modified":"2024-04-24T16:11:15","modified_gmt":"2024-04-24T16:11:15","slug":"install-powershell-7-1-0-apt-ubuntu-20-04-18-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2020\/11\/install-powershell-7-1-0-apt-ubuntu-20-04-18-04\/","title":{"rendered":"How to Install PowerShell 7.4.1 in Ubuntu 22.04, 20.04, 18.04"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7969\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2018\/07\/powershell-icon.png\" alt=\"\" width=\"245\" height=\"250\" \/><\/p>\n<p>Microsoft PowerShell 7.1.0 was released a few days ago with a number of improvements and fixes to PowerShell 7. Here&#8217;s how to install it in Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, and Linux Mint 19.x, 20.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/announcing-powershell-7-1\/\" target=\"_blank\" rel=\"noopener\">PowerShell 7.1.0<\/a> release highlights:<\/p>\n<ul>\n<li>Fix <code style=\"border: none; color: black;\">$?<\/code> to not be <code style=\"border: none; color: black;\">$false<\/code> when native command writes to <code style=\"border: none; color: black;\">stderr<\/code>.<\/li>\n<li>Rename <code style=\"border: none; color: black;\">-FromUnixTime<\/code> to <code style=\"border: none; color: black;\">-UnixTimeSeconds<\/code> on <code style=\"border: none; color: black;\">Get-Date<\/code> to allow Unix time input.<\/li>\n<li>Make <code style=\"border: none; color: black;\">$ErrorActionPreference<\/code> not affect <code style=\"border: none; color: black;\">stderr<\/code> output of native commands.<\/li>\n<li>Allow explicitly specified named parameter to supersede the same one from hashtable splatting.<\/li>\n<li>Make the switch parameter <code style=\"border: none; color: black;\">-Qualifier<\/code> not positional for <code style=\"border: none; color: black;\">Split-Path<\/code>.<\/li>\n<li>Resolve the working directory as literal path for <code style=\"border: none; color: black;\">Start-Process<\/code> when it&#8217;s not specified.<\/li>\n<li>Make <code style=\"border: none; color: black;\">-OutFile<\/code> parameter in web cmdlets to work like <code style=\"border: none; color: black;\">-LiteralPath<\/code>.<\/li>\n<li>Fix string parameter binding for <code style=\"border: none; color: black;\">BigInteger<\/code> numeric literals.<\/li>\n<li>On Windows, <code style=\"border: none; color: black;\">Start-Process<\/code> creates a process environment with all the environment variables from current session, using <code style=\"border: none; color: black;\">-UseNewEnvironment<\/code> creates a new default process environment.<\/li>\n<li>Do not wrap return result to <code style=\"border: none; color: black;\">PSObject<\/code> when converting ScriptBlock to delegate.<\/li>\n<li>Use invariant culture string conversion for <code style=\"border: none; color: black;\">-replace<\/code> operator.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741-700x475.webp\" alt=\"\" width=\"610\" height=\"414\" class=\"aligncenter size-large wp-image-46354\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741-700x475.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/powershell741.webp 786w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>How to Install PowerShell (7.4 Updated) in Ubuntu:<\/h3>\n<p>If you&#8217;re OK with containerized Snap package, simply search for and install powershell from Ubuntu Software.<\/p>\n<p>For those prefer <code>.deb<\/code> package, Microsoft offers the software in its official apt repository, so far supports Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04.<\/p>\n<p><b>1. Setup Microsoft apt repository in Ubuntu:<\/b><\/p>\n<p>Open <u>terminal<\/u> from your system application launcher. When it opens, run command to download the official .deb package:<\/p>\n<pre style=\"border: none;\">wget -q https:\/\/packages.microsoft.com\/config\/ubuntu\/$(lsb_release -rs)\/packages-microsoft-prod.deb -O packages-microsoft-prod.deb<\/pre>\n<p><i>For Linux Mint, replace <code>$(lsb_release -rs)<\/code> in the code with <code>20.04<\/code> for Linux Mint 20 (or <code>18.04<\/code> for Mint 19.x).<\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10517\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/wget-mspack.png\" alt=\"\" width=\"560\" height=\"107\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/wget-mspack.png 560w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/wget-mspack-450x86.png 450w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<p>Then install the package, which will install Microsoft repository and key, by running command:<\/p>\n<pre style=\"border: none;\">sudo dpkg -i packages-microsoft-prod.deb<\/pre>\n<p><i>Type user password (no asterisk feedback) for sudo prompts and hit Enter.<\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10518\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/setup-mspack.png\" alt=\"\" width=\"560\" height=\"96\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/setup-mspack.png 560w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/07\/setup-mspack-450x77.png 450w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<p><b>2. Install PowerShell:<\/b><\/p>\n<p>After adding the repository, run following 2 commands one by one to check package updates and install the software:<\/p>\n<pre style=\"border: none;\">sudo apt update\r\n\r\nsudo apt install powershell<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-32967\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/apt-powershell.png\" alt=\"\" width=\"600\" height=\"251\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/apt-powershell.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/apt-powershell-450x188.png 450w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Once installed, run <code>pwsh<\/code> to start PowerShell.<\/p>\n<h3>Uninstall PowerShell:<\/h3>\n<p>To remove the software, simply open terminal and run command:<\/p>\n<pre style=\"border: none;\">sudo apt remove powershell<\/pre>\n<p>To remove the apt repository, simply go to <i>Software &amp; Updates &gt; Other Software<\/i> tab, and remove the relevant line.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-32969\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/remove-powershell-repo.png\" alt=\"\" width=\"600\" height=\"285\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/remove-powershell-repo.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/11\/remove-powershell-repo-450x214.png 450w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>","protected":false},"excerpt":{"rendered":"<p>Microsoft PowerShell 7.1.0 was released a few days ago with a number of improvements and fixes to PowerShell 7. Here&#8217;s how to install it in Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, and Linux Mint 19.x, 20. PowerShell 7.1.0 release highlights: Fix $? to not be $false when native command writes to stderr. Rename -FromUnixTime to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1558],"class_list":["post-32966","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-powershell"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/32966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=32966"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/32966\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=32966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=32966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=32966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}