What is PowerShell and how it can be installed

What is PowerShell ? PowerShell is a command interpreter , a shell , a command line interface, with which you tell your operating system what to do and how to do it. And the way to tell your operating system what to do is through lines of text ,through text instructions .

Why use a command line shell instead of a graphical interface? Basically for productivity , and this is confirmed for two reasons. On the one hand, because a single command line can be enough to indicate exactly what you want to do. On the other hand, due to scripting automation . You can write that command line, or several, in a file to execute it later, as many times as you need.

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.

WHY POWERSHELL?

You may be wondering, why PowerShell? One of the advantages of PowerShell is that it is a cross-platform shell , being available in the main operating systems natively. Although you have to take it with a grain of salt since not all commands are available in all operating systems.

The other big question is do I need PowerShell? Is PowerShell for me? Will PowerShell work for me? Honestly, any scripting language will do . At the end of the day, it is an exceptional productivity tool , in that it will save you from repeating operations over and over again. Simply, you have to write those tasks in a script, and execute or even schedule their execution so that it starts when you need to.

Read: The best CMD commands for Windows

ABOUT POWERSHELL COMMANDS

Once, you already have an idea of ​​what PowerShell is , and the possibilities it has, and before installing PowerShell and preparing your work laboratory , here are some ideas and concepts, so that you can get an idea of what you are going to face .

The first idea or concept is that each PowerShell command indicates the action you are going to perform and what you are going to do it with. For example, the most often used command is Get-Help. Basically it returns a help text on 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?

The following command allows you to list all the processes that are running on your computer, or on the machine on which you are running PowerShell . To know which processes are being executed, simply run the following instruction in a PowerShell console.

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 .

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 .

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

For me, the best way to install PowerShell in Ubuntu is from the Microsoft repositories. The advantage of using the repositories is that, on the one hand, the installation is easier, but above all , that the PowerShell version is kept up-to-date. Every time an update is released, and is available in the repository, it will be updated on your system.

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 has a degree in software development. He is passionate about gadgets with a screen, nostalgic for phones, a retired gamer and open source programmer. He likes also to write about macOS and Windows. design web pages and debug long programs!

Leave a Reply