Yeah, you read right. I am now writing about Linux ;-). But only for this blog post. PowerShell Core 6.0 is a cross-platform tool, so I decided to write a small guide how to install PowerShell 6.0 Core on a Linux system.
For this task I am going to use Ubuntu 16.04.
Installation of PowerShell Core via Online Repository
This is the recommended method. PowerShell Core is published to repositories.
Import public keys
Firstly, we import the public repository keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Register Microsoft Repository
Then we have to register the Microsoft Ubuntu repository. Take care of the URL. As said, I’m using Ubuntu 16.04, so I have to provide this version in the URL. You’ll have to adjust that.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
Update list
Next we update the list of products.
sudo apt-get update
Installing PowerShell Core 6.0 on Linux
Now comes the exciting moment: Welcome PowerShell 6.0 on Linux!
sudo apt-get install -y powershell
Other installation methods can be found here:
First Steps
Enter pwsh. Welcome to PowerShell on Linux!
pwsh
Doing some basic tasks …
Get-ChildItem /etc
Get-Process
A few more demanding things…
Get-Process | Select-Object ProcessName,Id
Get-Uptime
New-Item -ItemType file -Name patrick.txt
Testing brackets and Foreach-Object …
1..10 | Foreach-Object {New-Item -ItemType file -Name file$_.txt}
That’s it for now. Have fun with PowerShell Core on Linux!
Categories: PowerShell
2 replies »