---
title: "Getting Advantage of PowerShell on Linux: A Beginner’s Guide"
description: "Learn how to get started automating and writing scripts with PowerShell on Linux in this informative tutorial."
canonical: "https://adamtheautomator.com/powershell-linux/"
---

# Getting Advantage of PowerShell on Linux: A Beginner’s Guide

> Learn how to get started automating and writing scripts with PowerShell on Linux in this informative tutorial.

Source: https://adamtheautomator.com/powershell-linux/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Getting Advantage of PowerShell on Linux: A Beginner’s Guide](https://adamtheautomator.com/wp-content/uploads/2021/07/Getting-Started-with-PowerShell-on-Linux-A-Beginners-Guide-1.jpg)

# Getting Advantage of PowerShell on Linux: A Beginner’s Guide

[![](https://secure.gravatar.com/avatar/1af914b6d78c9763370cebe4658d3cc0cbe27fa622f43f2cd4361dccdd36da8a?s=192&d=mm&r=g)AbdulMusawwir Khatri](https://adamtheautomator.com/author/abdulmusawwir-khatri/)27 July 20217 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Updating Package Repository](#h-updating-package-repository)
*   [Installing PowerShell on Linux](#h-installing-powershell-on-linux)
*   [Installing PowerShell via Snap Packages](#h-installing-powershell-via-snap-packages)
*   [Installing PowerShell via the .NET SDK](#h-installing-powershell-via-the-net-sdk)
*   [Running Basic PowerShell Commands on Linux](#h-running-basic-powershell-commands-on-linux)
*   [PowerShell on Linux Limitations](#h-powershell-on-linux-limitations)
*   [Windows -ne Linux](#h-windows-ne-linux)
*   [No Scheduled Jobs](#h-no-scheduled-jobs)
*   [Working with PowerShell Modules on Linux](#h-working-with-powershell-modules-on-linux)
*   [Finding Installed Modules](#h-finding-installed-modules)
*   [Installing PowerShell Modules on Linux](#h-installing-powershell-modules-on-linux)
*   [Running PowerShell Scripts From Bash](#h-running-powershell-scripts-from-bash)
*   [Conclusion](#h-conclusion)

Microsoft PowerShell has been traditionally thought of as a Windows-only product but not anymore. As of PowerShell v6, the full capabilities of PowerShell are now available cross-platform with Linux as the most popular.

In this tutorial, you’re going to learn how to get started from scratch by installing PowerShell on Ubuntu (other Linux distributions are similar), how to run commands, and even install some modules.

Let’s get started!

## Prerequisites

This tutorial will contain various demos. If you’d like to follow along, be sure you have the following:

*   Any [supported Linux distribution](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1) – This tutorial uses [Peppermint 10](https://peppermintos.com/) which is based on Ubuntu 18.04 (LTS).
*   An account with root access.

## Updating Package Repository

Before jumping to installing PowerShell on Linux, you must first update the apt package manager’s repository list. Some distributions of Linux use the [apt package manager](https://ubuntu.com/server/docs/package-management) to install apt packages; PowerShell is one of them.

To ensure that apt can find the PowerShell package and any dependency when downloading, you must first update apt’s package repository list. To do that, run `[apt update](<https://www.cyberciti.biz/faq/what-does-sudo-apt-get-update-command-do-on-ubuntu-debian/>)`.

```bash
sudo apt update
```

## Installing PowerShell on Linux

Now that you’ve updated the package repositories, it’s time to install PowerShell on Linux. Since this tutorial is using an Ubuntu-based distribution, you have two different ways to install PowerShell; using snap packages or via the [.NET SDK](https://dotnet.microsoft.com/download).

### Installing PowerShell via Snap Packages

The easiest way to install PowerShell on Ubuntu is via [snaps](https://snapcraft.io/). Snaps are packages that work across several Linux versions and distributions.

To install PowerShell on Linux via a snap package, open a terminal and run the `snap install` Linux command with `sudo` rights to using the snap package name of `powershell`.

> _By default, snap packages are limited in scope for security reasons. Specifying the `--classic` parameter allows you to make changes to your system outside the [security sandbox](https://www.goguardian.com/glossary/what-is-sandbox-security/)._

```bash
sudo snap install powershell --classic
```

![Installing PowerShell on Linux using Snap](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130030.597.png)

Installing PowerShell on Linux using Snap

### Installing PowerShell via the .NET SDK

1\. Sometimes you’ll find that the PowerShell snap package does not contain the latest version of PowerShell. When that happens, you can always opt for the .NET SDK route which is always going to be updated.

PowerShell is packaged with .NET Core so when you install the .NET SDK, you get PowerShell too!

Download and install the latest available .NET SDK by running the below command using the `apt` package manager. As of this writing, the latest available .NET SDK package is v5.0.8. You can check the latest available version [here](https://dotnet.microsoft.com/download/dotnet).

```bash
sudo apt install dotnet-sdk-5.0
```

![Installing the latest .Net SDK on Ubuntu](https://adamtheautomator.com/wp-content/uploads/2021/07/2_InstallDotNet5.png)

Installing the latest .Net SDK on Ubuntu

2\. Now, install PowerShell via the `dotnet` application using `dotnet tool install`. The `dotnet tool` command specifies a NuGet package which PowerShell is packaged as.

By specifying the `--global` option, `dotnet` installs the PowerShell package to _~\\.dotnet\\tools_ and ensures the directory is in the system PATH so you can execute it from anywhere.

```bash
dotnet tool install --global PowerShell 
```

![Installing PowerShell via the .Net SDK](https://adamtheautomator.com/wp-content/uploads/2021/07/4_InstallingPWSH_DotNet.png)

Installing PowerShell via the .Net SDK

## Running Basic PowerShell Commands on Linux

Now that you have PowerShell installed on Linux, what next? Let’s start by running a few basic commands. To start PowerShell, simply run `pwsh` and you’ll be dropped into the PowerShell interactive console.

![Running PowerShell on Linux](https://adamtheautomator.com/wp-content/uploads/2021/07/5_OpeningPWSH.png)

Running PowerShell on Linux

Being a cross-platform scripting language, PowerShell on Linux supports all of the commonly known commands from CMD and Linux’s command line shell such as `sudo apt update`. No need to open a Bash terminal!

![Updating Linux package repositories using PowerShell core](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130338.439.png)

Updating Linux package repositories using PowerShell core

From here on out you can run thousands of built-in [PowerShell commands](https://www.pdq.com/powershell/). While you’re at it, check what version of PowerShell is installed using `$PSVersionTable`. You should see that the PSEdition shows as **Core** and **Platform** is **Unix**.

![Checking the installed version of PowerShell core on Linux](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130406.646.png)

Checking the installed version of PowerShell core on Linux

Once you’re done in the PowerShell console, exit by running the `exit` command. This command will drop you back into your Bash terminal.

## PowerShell on Linux Limitations

Just because you can install PowerShell and run commands on it doesn’t necessarily mean you can do everything possible on Windows. After all, Linux being Open Source, is a completely different operating system and some commands will not be available for features not available in Linux.

### `Windows -ne Linux`

For example, since Linux doesn’t have a registry, you won’t see any PowerShell drives. The `Get-PSDrive` cmdlet will still be available but it will only return the mounted Linux storage volumes and other standard PS Drives. You can see an example below.

```powershell
Get-PSDrive | Format-Table -Auto
```

![Get-PSDrive command on PowerShell Core](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130445.792.png)

Get-PSDrive command on PowerShell Core

Unlike Microsoft Windows, Linux neither has [Common Information Model (CIM)](https://en.wikipedia.org/wiki/Common_Information_Model_\(computing\)) nor [Windows Management Instrumentation (WMI)](https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page). Both of these assist in providing information about the management of devices and applications to the Windows operating system.

You can see below that the Windows PowerShell cmdlet `Get-CimInstance` isn’t available in PowerShell on Linux.

```powershell
Get-CimInstance -ClassName Win32_BIOS
```

![Retrieving BIOS information via CIM on PowerShell Core on Linux](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130544.565-1.png)

Retrieving BIOS information via CIM on PowerShell Core on Linux

But if you try to use `Get-CimInstance` in Windows PowerShell, you’ll see below that it works as expected.

![Retrieving BIOS information via CIM on PowerShell on Windows](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130721.817.png)

Retrieving BIOS information via CIM on PowerShell on Windows

### No Scheduled Jobs

Another drawback of PowerShell on Linux is the lack of [scheduled jobs](https://devblogs.microsoft.com/scripting/introduction-to-powershell-scheduled-jobs/). Scheduled jobs are a handy feature in Window PowerShell that allows you to run tasks in the background via the Windows Task Scheduler.

Related:[How to Set up and Manage Scheduled Tasks with PowerShell](https://adamtheautomator.com/powershell-scheduled-task/)

To create a scheduled job in Windows PowerShell requires you to _register_ the job via the [`Register-ScheduledJob` cmdlet](https://docs.microsoft.com/en-us/powershell/module/psscheduledjob/register-scheduledjob?view=powershell-5.1). You’ll see an example of copying some Excel workbooks that works in Windows PowerShell below. You’ll notice that the `Register-ScheduledJob` cmdlet isn’t found.

![Registering a Scheduled Job via PowerShell Core on Linux](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130748.226.png)

Registering a Scheduled Job via PowerShell Core on Linux

Although you can’t schedule a job, you can still invoke background jobs using the `Start-Job` command. The `Start-Job` cmdlet allows you to run background jobs in PowerShell to execute a task with no interaction with the current session.

Perhaps you’d like to list all files in _/var/backups_ but do so in the background. You could create the command to execute in a `ScriptBlock` and create a job called `GetAllBackupFiles` invoke with `Start-Job`, as shown below.

```powershell
Start-Job -Name GetAllBackupFiles -ScriptBlock {Get-ChildItem /var/backups -Recurse}
```

![Starting a background job to get a list of files in the /var/backups directory.](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130843.709.png)

Starting a background job to get a list of files in the /var/backups directory.

Once the background job starts, you can then receive the output from that job using the `Retrieve-Job` cmdlet by specifying the `-Name` that you provided when starting it.

```powershell
Retrieve-Job -Name GetAllBackupFiles
```

![Retrieving the output from the background job.](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130908.148.png)

Retrieving the output from the background job.

## Working with PowerShell Modules on Linux

An important concept in Windows PowerShell is the PowerShell module. PowerShell modules are groups of commands built as “packages” built both from Microsoft and via the PowerShell community.

Related:[Understanding and Building PowerShell Modules](https://adamtheautomator.com/powershell-modules/)

### Finding Installed Modules

By default, PowerShell on Linux, like Windows, installs various modules. Find all of those modules by running the `Get-Module` command, as shown below. The `ListAvailable` parameter tells `Get-Module` to return _all_ modules on the filesystem; not just loaded modules.

```powershell
Get-Module -ListAvailable
```

You can see below that the **Pester** module is installed in _/root/.local/share/powershell/Modules_ which is the user location for PowerShell modules. You’ll learn how to install modules in an upcoming section.

![Checking the location of a stored PowerShell module on Linux](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T130956.196.png)

Checking the location of a stored PowerShell module on Linux

You can see each location to install modules by looking at the `PSModulePath` environment variable, as shown below. Since the value of `$env:PSModulePath` is one string, the tutorial is using the [`split` operator](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7.1) to split the string on colons (not semicolons like Windows) to display each path on a different line.

```powershell
$env:PSModulePath -split ':'
```

![PowerShell module locations](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T131049.411.png)

PowerShell module locations

### Installing PowerShell Modules on Linux

Even though PowerShell on Linux comes with various modules already installed, chances are you’re going to need more functionality. When that happens, you can leverage the [PowerShell Gallery](https://www.powershellgallery.com/). The PowerShell Gallery is a repository of thousands of modules that work both in Windows and Linux.

Using the `Install-Module` cmdlet, you can install modules on Linux just like you can on Windows. But first, you should find the module you’re looking for using `Find-Module`.

Let’s say you’d like to run some Pesters tests using the popular [Pester testing framework](https://adamtheautomator.com/powershell-test/). Pester comes packaged in a module. Check to see if the Pester module is available in the PowerShell Gallery using the `Find-Module` cmdlet.

```powershell
Find-Module Pester
```

You can see below that `Find-Module` found the available Pester module.

![Verifying Module Source](https://adamtheautomator.com/wp-content/uploads/2021/07/Selection_020.png)

Verifying Module Source

Once you’ve verified the Pester module is available, now install the module using the `Install-Module` cmdlet specifying the `Name` of the module.

```powershell
Install-Module -Name Pester
```

When you run `Install-Module`, PowerShell will prompt you about an untrusted repository because the repository is marked as [untrusted](https://evotec.xyz/powershellgallery-you-are-installing-modules-from-an-untrusted-repository/). For testing, this warning is nothing to worry about so type _A_ to confirm.

![Installing Module](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T131148.822.png)

Installing Module

Once the module has been installed, now run the `Get-InstalledModule` cmdlet and you’ll see that Pester has been installed and its commands are now available.

![Retrieving a list of installed modules on PowerShell Core.](https://adamtheautomator.com/wp-content/uploads/2021/07/Selection_019.png)

Retrieving a list of installed modules on PowerShell Core.

You’ll also see that by using the `Get-Command` cmdlet, you can also find all commands inside of the `Pester` module, as shown below.

```powershell
Get-Command -Module Pester
```

![Commands that are available from the Pester Module.](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T131235.402.png)

Commands that are available from the Pester Module.

## Running PowerShell Scripts From Bash

To wrap up this tutorial, let’s end with running PowerShell scripts from Bash. Throughout this tutorial, you’ve been interactively running PowerShell commands inside of a PowerShell console. If you have a PowerShell script you need to execute, there’s no need to drop into the PowerShell console. Instead, you can execute the script directly from Bash.

To demonstrate running a PowerShell script from Bash, open your favorite Linux text editor and paste the following command and save the file as _DrivesInformation.ps1_. This script will simply enumerate all of the PS drives.

```powershell
Get-PSDrive
```

In your Bash terminal, instead of running `pwsh`, hitting Enter and then running the script inside of the PowerShell console, invoke the script directly from Bash. To do this, run `pwsh` again but this time specify the PowerShell script you just created, as shown below.

You’ll see that you receive the same output you would inside of the interactive PowerShell session directly in your Bash terminal.

```powershell
pwsh /home/tex/DrivesInformation.ps1
```

![Running a PowerShell script from Bash via the installed PowerShell core](https://adamtheautomator.com/wp-content/uploads/2021/07/Untitled-2021-07-26T131316.819.png)

Running a PowerShell script from Bash via the installed PowerShell core

## Conclusion

You should now have a good start at running PowerShell in Linux! It’s now up to you to start learning more about PowerShell and automating all you can!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-linux%2F&text=Getting%20Advantage%20of%20PowerShell%20on%20Linux%3A%20A%20Beginner%E2%80%99s%20Guide)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-linux%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-linux%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2021/01/How-to-Find-and-Kill-Processes-in-Linux.jpg)

### [Master Linux Kill Process Using ps, pgrep, pkill and More](/linux-kill-process/)

Learn the many ways of finding processes with ps, top, psgrep, and get-process and kill processes in Linux with the kill, killall, and stop-process commands

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
