Microsoft’s PowerShell is without question a very powerful management tool/automation tool, especially for those who use Windows. Many developers have also started to embrace PowerShell and it has even seen native releases for MacOS and Linux. Thanks to the magic of Chrome OS and Crostini, it can also be installed on a Chromebook, here is how:
Note : This will only work for AMD64/X64 Chrome OS devices. It may be possible to manually build the source code for ARM but that is currently out of scope for this article.
Go ahead and fire up your favorite terminal application and run the following:
sudo apt install curl gnupg apt-transport-https liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu4 wget
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list'
sudo apt-get update
sudo apt-get install -y powershell
sudo apt-get install -f
Once the installation is complete, you will have a working version of PowerShell setup on your Chrome OS device. Unlike other applications, there will not be a Chrome Launcher Icon for PowerShell, you instead need to launch it via a command line via a Terminal by typing “pwsh”
What many new to PowerShell on Linux may not know is that it can run many standard bash commands (such as ls, mkdir, rm, etc) and it will also run the Windows-like versions (dir, mkdir, del, etc) at the same time. If you want to get started with PowerShell on Linux, I highly recommend the book “PowerShell 6.0 Linux Administration Cookbook” as it provides several excellent examples specifically tailored to Linux.
I tried pasting the code above into the crosh prompt….
but it comes back with ERROR: unknown command: sudo.
What do I do?
You should be entering it in the Crostini “Linux Terminal”, not crosh
The following packages have unmet dependencies:
powershell : Depends: libssl1.0.0 but it is not installable
Depends: libicu55 but it is not installable
E: Unable to correct problems, you have held broken packages.
Just after updating my Acer Chromebook 314 to “Chrome OS Version 83.0.4103.77 (Official Build) (64-bit)” I had a similar problem:
powershell : Depends: libssl1.0.2 but it is not installable
Depends: libicu57 but it is not installable
E: Unable to correct problems, you have held broken packages.
Debian is now buster, not stretch, so I changed the echo above:
sudo sh -c ‘echo “deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-buster-prod buster main” > /etc/apt/sources.list.d/microsoft.list’
I got PowerShell 7.0.1:
PS /home/granchee> $PSVersionTable
Name Value
—- —–
PSVersion 7.0.1
PSEdition Core
GitCommitId 7.0.1
OS Linux 4.19.113-08528-g5803a1c7e9f9 #1 SMP PREEMPT Thu Apr 2 15:21:14 PDT 2020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This was helpful: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7
Hello,
This post is a bit old and instructions do change with each upgrade. I am working on something to make it easier to keep updated.