How To Install PowerShell In Linux
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
We are starting a new blog series in one of the most popular and power full scripting language PowerShell. In today’s blog post we will discuss how to install and upgrade PowerShell.
What Is PowerShell?
PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and scripting language. Unlike most shells, which accept and return text, PowerShell is built on top of the .NET Common Language Runtime (CLR), and accepts and returns .NET objects. This fundamental change brings entirely new tools and methods for automation.
PowerShell features:
- The commands in PowerShell are known as cmdlets. Like many shells, PowerShell gives you access to the file system on the computer using cmdlets.
- PowerShell cmdlets are designed to deal with objects. An object is structured information that is more than just the string of characters appearing on the screen. Command output always carries extra information that you can use if you need it.
- PowerShell supports aliases to refer to commands by alternate names.
- PowerShell always processes the command-line input directly and formats the output that you see on the screen. This ensures that you can always do things the same way with any cmdlet.
- PowerShell supports pipeline where you can pass one cmdlet output, item by item, to the next cmdlet. Further PowerShell pipes objects, not text, between commands which reduces the complexity of processing text and increases the productivity.
- PowerShell includes detailed help articles that explain PowerShell concepts and command syntax. Use the Get-Help cmdlet to display these articles at the command prompt.
How To Install PowerShell:
PowerShell Installation On Windows:
Most of the windows system comes with PowerShell pre-installed. You can check if PowerShell is already installed and which version of PowerShell installed by opening cmd.exe and typing PowerShell. PowerShell will open if installed or will throw an error. Execute $PSVersionTable to get the current PowerShell version. To install the latest PowerShell version using command prompt, follow below steps –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
############################### ## PowerShell | Installation ## ############################### ## ----------- ## OS: Windows ## ----------- ## Step 1: Download the latest release of PowerShell from official PowerShell GitHub repository ## https://github.com/PowerShell/PowerShell/releases ## https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x64.msi ## Step 2: Open cmd from run and execute below command msiexec.exe /package PowerShell-7.0.3-win-x64.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ` ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1 ## Step 3: Once installation completed, check the PowerShell version ## Start ==> Search PowerShell ==> Click PowerShell $PSVersionTable ## get powershell version details |
PowerShell Installation On Linux:
You can install PowerShell in almost all popular Linux operating systems where .NET core is supported. Packages for each OS type can be found in GitHub. In this blog post, I am going to cover PowerShell installation in CentOS 7 and Ubuntu 18 version. Once the PowerShell is installed you can start a PowerShell session using pwsh command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
## ---------- ## OS: Ubuntu ## ---------- # Download the Microsoft repository GPG keys wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb ## for Ubuntu version 16 wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb ## for Ubuntu version 18 # Register the Microsoft repository GPG keys sudo dpkg -i packages-microsoft-prod.deb # Update the list of products sudo apt-get update # Enable the "universe" repositories sudo add-apt-repository universe # Install PowerShell sudo apt-get install -y powershell # Start PowerShell pwsh ## ---------- ## OS: CentOS ## ---------- # Register the Microsoft RedHat repository curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo # Install PowerShell sudo yum install -y powershell # Start PowerShell pwsh |
Hope you have enjoyed this article. In the next blog post, we will discuss how to get started with PowerShell.
To install PowerShell on any other OS, please follow below official documentation
To get more details on PowerShell, kindly follow below official documentation