What is PowerShell and how it can be installed

Updated on 8/1/2023 – PowerShell is a tool for issuing commands to an operating system, either through a command line interface or by writing scripts. One benefit of using a command line shell is increased productivity, as a single command can accomplish a task and multiple commands can be saved in a script for future use. Another advantage is automation, as scripts can be run repeatedly without the need for manual input.

Writing your command in a terminal, or commands in a file, is what is known as scripting . PowerShell is also a powerful tool to implement your own scripts.

Read: How to fix Powershell error: Running scripts is disabled on this system

WHY POWERSHELL?

PowerShell is a command-line interface that allows users to input and execute text-based instructions to their operating system. It is known for its productivity-enhancing capabilities, such as the ability to execute a single command or multiple commands stored in a script file. PowerShell is available on multiple platforms, but not all commands are compatible with all operating systems. While any scripting language can be used to automate tasks and improve productivity, PowerShell is a particularly effective tool for this purpose. It can be used to save time by avoiding the need to repeat tasks manually, and scripts can be executed or scheduled for execution at a desired time.

Read: The best CMD commands for Windows

ABOUT POWERSHELL COMMANDS

Before installing PowerShell and setting up your work environment, it’s helpful to have an understanding of the basics. One key concept to know is that each PowerShell command specifies an action to be taken and the object on which it will be performed. For instance, the commonly used command “Get-Help” returns a help text for a specific command.

Get-Help powershell windows 10

Once executed on the command line, it will show you information about the command you want to report on.

Get-Help Get-Help

The above instruction uses Get-Help To show you information about Get-Help. In this case, it will give you a result like the one you can see below:

Get-Help powershell example

GETTING FAMILIAR WITH POWERSHELL

Now that you know the syntax of PowerShell commands, we will show you some examples of what you can do with them.

Read: Processes in Linux –  Guide for beginners

WHAT PROCESSES ARE RUNNING ON MY COMPUTER?

To view the currently running processes on your computer or the machine you are using PowerShell on, you can use the command “Get-Process”. This command will display a list of all processes that are currently running.

But what if you just want to know about a certain process? In this case, you have to add a parameter to your CmdLet .i.e. the name of the process. You can do this in the following way:

Get-process -Name explorer

In the above command, the process is called explorer.

If you want to know all the CmdLet and functions that are available in your operating system, you can use the CmdLet Get-Command .

Read: An introduction to Windows PowerShell for beginners

ABOUT ALIASES

What if you want to know the files that are in your current the directory? For this you have the CmdLet Get-ChildItem . If I run it on my computer and in the directory I am in I will get something like,

And now you may be thinking that you have to learn new instructions for old commands. I mean, you did this yourself with dir. Good news , in PowerShell , you can also use dir .

Read: How to change the priority of WiFi networks in Windows 10

This is what is known as an alias . You basically give some commands a nickname to make it more convenient for you to use them.

What aliases do you have available to use? Again you have to resort to another CmdLet , it is Get-Alias, which is the one that will be in charge of showing you all the aliases that are defined at the time of executing the instruction. For example, if I run Get-Alias on the computer that I am on right now, it will show me something like the following :

INSTALL POWERSHELL ON WINDOWS

To install PowerShell in Windows this has to be either Windows 7 SP1, or Windows Server 2008 R2 or any newer version.

Also, to be able to use PowerShell remotely, you need:

INSTALLATION FROM THE APP STORE

PowerShell 7.1 is in the application store, and you can install it perfectly from there. This option has some advantages, such as automatic updates or integration with other software distribution mechanisms.

However, this installation process also has certain limitations. This results from the fact that MSIX packages run in an application sandbox, so the access to some registry and file system locations is virtualized.

INSTALLATION

You can install PowerShell using an MSI installation file or from a compressed ZIP file . For both, Powershell download can be initiated using the installation package from GitHub .

Depending on the architecture of your computer, you have different installation packages. For example,

In the case of using the installer, you can install PowerShell from the command line by executing the following instruction,

In the event that you install it using a ZIP package , once the package is downloaded, you have to unzip the content in the directory of your choice and then execute pwsh.exe.

Although, when you install with the installer , the requirements for the correct operation of PowerShell are checked, in the case that the installation is done with the ZIP package, this is not verified.

INSTALL POWERSHELL ON LINUX

As I have told you in Windows, you can also install PowerShell in Linux, from the package. You simply have to download the installation package from GitHub , selecting the one that corresponds to your distribution and the architecture of your OS. So you have a version for,

  • Alpine 3.11
  • CentOS 8
  • Debian versions 9, 10 and 11
  • RedHat 7
  • Ubuntu versions 16.04, 18.04 and 20.04

You also have the option of installing PowerShell using the PowerShell snap package or even using the PowerShell binaries directly from the tar.gz file .

Read: 4 Benefits of Compressing Files and Folders Using Tar Backup in Linux OS

INSTALLING POWERSHELL ON UBUNTU

Installing PowerShell from Microsoft’s repositories is the recommended method for obtaining the latest version in Ubuntu. Not only is the installation process easier this way, but you will also receive updates automatically as they become available. This ensures that your version of PowerShell stays current.

To install, you have to run the following instructions:

source /etc/os-release

sudo apt update

sudo apt install wget apt-transport-https software-properties-common

wget -q https://packages.microsoft.com/config/ubuntu/${VERSION_ID}/packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

sudo apt update

sudo add-apt-repository universe

sudo apt install powershell

INSTALLING POWERSHELL ON DEBIAN

As in the case of Ubuntu, also in Debian, you can install PowerShell from the repository.

INSTALLING POWERSHELL ON RASPBERRY PI OS

If you want to install PowerShell on your Raspberry, you will need a little more work. You have to download the latest version available for ARM32. For example to install version 7.0.4, follow the steps below:

POWERSHELL IN A CONTAINER

If you don’t want to install PowerShell, but you already have Docker installed, an interesting option is to use PowerShell in a container. For this, you just have to execute the instruction:

Read: How to install Docker Compose on Ubuntu 20.04

You also have the option of running PowerShell in a container using Podman , the variant of Docker that doesn’t use a daemon . In the same way as in the previous case, the execution is as simple as in the previous case, but substituting docker for podman, as you can see below:

 


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Nikolaus Oosterhof

Nikolaus holds a degree in software development and has a strong passion for all things tech-related, especially gadgets with screens. Though he is nostalgic for older phone models, he's a retired gamer and continues to enjoy programming in open-source environments. Additionally, Nikolaus enjoys writing about Linux, macOS and Windows and has experience designing web pages.

Leave a Reply