PowerShell

Installing PowerShell 7 on Linux via Public Repository

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 -

1.JPG

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

2.jpg

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

4.JPG

Other installation methods can be found here:

https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-powershell-core-on-macos-and-linux?view=powershell-5.1

First Steps

Enter pwsh. Welcome to PowerShell on Linux!


pwsh

5.JPG

Doing some basic tasks …


Get-ChildItem /etc

7.JPG


Get-Process

8.JPG

A few more demanding things…


Get-Process | Select-Object ProcessName,Id

9


Get-Uptime

10.JPG


New-Item -ItemType file -Name patrick.txt

11.JPG

Testing brackets and Foreach-Object …


1..10 | Foreach-Object {New-Item -ItemType file -Name file$_.txt}

Unbenannt.JPG

That’s it for now. Have fun with PowerShell Core on Linux!

Categories: PowerShell

Tagged as: ,

2 replies »

Leave a comment

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