First, I try to get Powershell 7, per the instruction at Microsoft.
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# nothing happens
# Update the list of products
sudo apt-get update
#dpkg: error processing archive packages-microsoft-prod.deb (--install):
# cannot access archive: No such file or directory
#Errors were encountered while processing:
# packages-microsoft-prod.deb
# Install PowerShell
sudo apt-get install -y powershell
#Reading package lists... Done
#Building dependency tree
#Reading state information... Done
#E: Unable to locate package powershell
# Start PowerShell
pwsh
#No command 'pwsh' found, did you mean:
# Command 'posh' from package 'posh' (universe)
# Command 'push' from package 'heimdal-clients' (universe)
# Command 'pdsh' from package 'pdsh' (universe)
# Command 'ppsh' from package 'ppsh' (universe)
#pwsh: command not found
Clearly that did not work. Sadly,
wget
and/or packages.microsoft.com
are blocked from my new server. wget
exists, but there is some conflict. Hmm.
wget -S --spider https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
Spider mode enabled. Check if remote file exists.
--2019-08-19 14:40:34-- https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
Resolving packages.microsoft.com (packages.microsoft.com)... 40.76.35.62
Connecting to packages.microsoft.com (packages.microsoft.com)|40.76.35.62|:443... failed: Connection refused.
But wait.. I was able to download Powershell 7 for Windows, so why not just download the .deb file and do it manually? One download and an sftp session later, and here I go:
#Use the actual package name
sudo dpkg -i powershell_6.2.0-1.ubuntu.16.04_amd64.deb
sudo apt-get install -f
Well, that was easy. Hey, how come...?
$ which powershell
$ which powershell-preview
$ which pwsh
I guess I need to find it? I am a bit lazy, so:
sudo find / -name pwsh
/opt/microsoft/powershell/7-preview/pwsh
So, add that to your PATH variable:
$ PATH=$PATH:/opt/microsoft/powershell/7-preview
$ echo $PATH
/home/vdev2/bin:/home/vdev2/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/microsoft/powershell/7-preview
$ which pwsh
/opt/microsoft/powershell/7-preview/pwsh
So...
$ pwsh
PowerShell 7.0.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
PS /home/dave>
That whole copyright/help section is a bit of a pain, though. Doing a quick info pwsh however, show me we can throw standard Powershell arguments at the Linux version.
$ pwsh -NoLogo
PS /home/vdev2>
So, we can change our
.bashrc
file to contain that switch and never see it again, and add an alias so we can use powershell
, if we want:
alias pwsh='pwsh -NoLogo'
alias powershell='pwsh -NoLogo'
Then reload our profile, and we are done.
$ exec bash
$ pwsh
PS /home/vdev2>
Viola!