How to Download and Install PowerShell 7 on Windows, Linux, and macOS
Tags: powershell
Published: 2021-01-14 20:34:32

> _This article was written by Jeff Christman. He is a frequent contributor to the Adam the Automator (ATA) blog. If you'd like to read more from this author, check out his [ATA author page](http://adamtheautomator.com/author/jeff). Be sure to also check out [more how-to posts on cloud computing, system administration, IT, and DevOps on adamtheautomator.com](https://adamtheautomator.com)!_

<!-- wp:paragraph -->
<p>Nowadays, sysadmins are required to know more than one operating system. That used to mean learning more than a few shell scripting languages. PowerShell Core and by downloading and installing PowerShell 7, you can change that.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It's no longer necessary to learn a new scripting language to support heterogeneous environments with PowerShell 7. PowerShell 7 is cross-platform meaning it can be installed on Windows, Linux, and other operating systems.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>PowerShell 7 is supported on Windows, macOS, and Linux. It's open-source, built for heterogeneous environments and the hybrid cloud. PowerShell Core has recently become available on Windows internet of things (IoT) as well.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The cross-platform nature of PowerShell 7 means that the scripts that you write will run on any supported operating system.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="powershell-core-vs-windows-powershell">PowerShell 7 vs. Windows PowerShell</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The main difference between Windows PowerShell and PowerShell 7 is the platform they are built on.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Windows PowerShell is built on top of the .NET frameWork. Because of that dependency, it's only available on Windows and is launched as <em>powershell.exe</em>.</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>Note that you can run PowerShell 7 and Windows PowerShell side by side. In fact, there is no way to completely remove Windows PowerShell anyway.</em></p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>PowerShell 7 is built on .NET Core and is available cross-platform and is launched as <em>pswh.exe</em>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="installing-powershell-core">Installing PowerShell 7</h2>
<!-- /wp:heading -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p><em>This tutorial will focus on installing the latest release of PowerShell 7 at the time of this writing which is PowerShell 7.1.</em></p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>There are different processes to get PowerShell 7 installed on various operating systems. Let's cover each one.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="windows">Windows</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To install PowerShell 7 on Windows, navigate to the PowerShell <a href="https://github.com/PowerShell/PowerShell/releases">GitHub repository</a> and download the <em>.msi</em> package appropriate for your system. Then run through the wizard. Easy peasy.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="windows-iot">Windows IoT</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Windows Iot devices already have PowerShell installed which we will use for installing Powershell Core</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="powershell" class="language-powershell">
#Enter a psession to the device
$s = New-PSSession -ComputerName &lt;deviceIp&gt; -Credential Administrator

#Copy the file to the device
<a class="wpil_keyword_link" title="Copy-Item" data-wpil-keyword-link="linked" href="https://adamtheautomator.com/copy-item-copying-files-powershell/">Copy-Item</a> .\PowerShell-7.1.0-win-x64.msi -Destination u:\users\administrator\Downloads -ToSession $s

#Connect to the device and expand the archive
Enter-PSSession $s
Set-Location u:\users\administrator\downloads
Expand-Archive .\PowerShell-7.1.0-win-x64.zip

#Setup Remoting
Set-Location .\PowerShell-7.1.0-win-x64

# Be sure to use the -PowerShellHome parameter otherwise it'll try to create a new endpoint with Windows PowerShell 5.1
.\Install-PowerShellRemoting.ps1 -PowerShellHome .

# You'll get an error message and will be disconnected from the device because it has to restart WinRM
# Connect to the device. Be sure to use the -Configuration parameter. If you omit it, you will connect to Windows PowerShell 5.1
Enter-PSSession -ComputerName &lt;deviceIp&gt; -Credential Administrator -Configuration powershell.7.1.0</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Once in the session, you should then be running PowerShell on the IoT device!</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="ubuntu-debian">Ubuntu, Debian</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For Linux distributions, it just a matter of adding the repository and installing with the package manager.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="bash" class="language-bash">
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of products
sudo apt-get update

# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell
pwsh</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3 id="centos-and-redhat">CentOS and RedHat</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="bash" class="language-bash">
# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

# Install PowerShell
sudo yum install -y powershell

# Start PowerShell
pwsh</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3 id="opensuse">OpenSUSE</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="bash" class="language-bash"># Register the Microsoft signature key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

# Add the Microsoft Repository
zypper ar https://packages.microsoft.com/rhel/7/prod/

# Update the list of products
sudo zypper update

# Download and Install PowerShell 7
sudo zypper install powershell

# Start PowerShell
pwsh</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3 id="fedora">Fedora</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="bash" class="language-bash"># Register the Microsoft signature key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

# Update the list of products
sudo dnf update

# Install a system component
sudo dnf install compat-openssl10

# Download and Install PowerShell 7
sudo dnf install -y powershell

# Start PowerShell
pwsh</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3 id="macos">MacOS</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For macOS, Homebrew is the preferred package manager. Installing Homebrew package manager is a single line command from a terminal, then install Powershell Core.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code lang="bash" class="language-bash">
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

#install PowerShell Core
brew cask install powershell

#start session
pwsh</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2 id="summary">Summary</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Learn to manage different platforms and OSs. It'll only help your career. When you need a cross-platform scripting language, try out PowerShell Core to write once and deploy everywhere. It's another tool in your toolbox.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you don't learn it, someone else will.</p>
<!-- /wp:paragraph -->