Configuring PowerShell Core 6 For Your Environment

PowerShell Core 6

There are several reasons that you may want to use PowerShell Core 6. Some people like bigger numbers and 6 is definitely bigger than 5. Others may have some Linux machines in their environment and would prefer to use PowerShell’s object-oriented goodness when interacting with it.

No matter your reasons for it, the first thing you have to do is get it configured for your environment. Join me while we go on an adventure to discover the requirements and set up steps that allow you to remote into your Linux machines from a PowerShell console.

Before we get started we need to point out that while PowerShell Core 6 adds cross-platform functionality, it is different from Windows PowerShell 5.1. As it currently stands, it has significantly less functionality. This is a great tool to help you control other operating systems in your environment, but for your day to day Windows tasks, Windows PowerShell 5.1 is still your best bet.

Setting Up Linux

Installing PowerShell Core 6

PowerShell Core is published to package repositories, so installing it is pretty straightforward.

1. First, import the public repository GPG keys

curl | sudo apt-key add

Setting Up Linux - Installing Powershell Core 6 -1

2. Then, register the Microsoft Ubuntu Repository, this makes updating to future releases easier

curl | sudo tee /etc/apt/sources.list.d/microsoft.list

Setting Up Linux - Installing Powershell Core 6 - 2

3. Next, update the list with the newest versions of the packages

sudo apt-get update

Setting up Linux - Installing Powershell Core 6 - 3

4. Install PowerShell

sudo apt-get install -y powershell

Setting Up Linux - Installing Powershell Core 6 - 4

Setting Up OpenSSH

Now that we have PowerShell installed we need to set up OpenSSH to allow it to use PowerShell for ssh connections.

1. Modify the config file

Sudo Nano /etc/ssh/sshd_config

2. Add the following line below any existing subsystem lines in the document

Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

3. Restart the sshd service

sudo service sshd restart

Linux is now all set up to allow ssh from PowerShell Core 6.

Setting Up Windows

Installing PowerShell Core 6

1. Download the latest release from here.
2. Run the msi
3. Follow all of the prompts

Installing OpenSSH

1. First, download the latest release by clicking here.
2. Then, extract all the contents to “C:\Program Files\OpenSSH”
3. From an elevated console run:

PowerShell.exe -ExecutionPolicy bypass -File “C:\Program Files\OpenSSH\install-sshd.ps1”

4. Press “Win” + “R” and type SystemPropertiesAdvanced
5. Click on Environment Variables Button

Installing OpenSSH - 1
6. Highlight Path from system variables and click Edit

Installing OpenSSH - 2
7. Add a line for C:\Program Files\OpenSSH\

Installing OpenSSH - 3

Note: (adding this requires you to log out and back in for it to work)

Optional: Allowing ssh into your Windows machine

With this setup, you will be able to ssh into your Linux machine, but machines will not be able to ssh into your Windows box. If you would like it to work all around you will need to make three changes.

1. First, add a firewall rule to allow TCP over port 22. Run the following from an elevated PowerShell window

“netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22”

2. Then, open file “C:\ProgramData\ssh\sshd_config” in Notepad
3. After, add the following line below any existing subsystem lines in the document. Replacing with the version of PowerShell that you installed

Subsystem powershell c:\program files\powershell\\6.0.2\pwsh.exe

4. Finally, restart the sshd service

Use SSH With PowerShell

All set! You can test it out with either:

Invoke-Command or Enter-Pssession

Invoke-Command -Hostname (Hostname or IP) -UserName (Username) -ScriptBlock {script}

Using SSH With PowerShell - 1


Enter-PsSession -Hostname (Hostname or IP) -Username (Username)

Using SSH With PowerShell - 2

You’re Done!

Now, you have the power and knowledge to use PowerShell Core 6!  You can continue to use Linux through putty or something like an animal, or you can be the first in your company to jump into the FUTURE!

Watch our latest video about this topic for more helpful information.


Start a trial of PDQ Deploy

Your email address will not be published.

Your Name

This site uses Akismet to reduce spam. Learn how your comment data is processed.