book of spells.webp

Start your journey towards mastering the CLI with our FREE Command Line Book of Spells.

By entering your email address you agree to receive emails from Command Line Wizardry. We'll respect your privacy and you can unsubscribe at any time.

  • Paul Troncone

Running PowerShell on Linux

PowerShell is a command shell and scripting language developed by Microsoft in the mid-2000's. It was originally designed for use in the Windows operating system, but more recent releases have added support for Linux, macOS, and ARM environments.

Installing PowerShell on Linux

On many Linux distributions PowerShell can be installed using the Advanced Package Tool (APT). First update your available packages:

Next install PowerShell:

Once installed, you can launch PowerShell using pwsh.

For more advanced installation instructions, or to install PowerShell on macOS or ARM environments see Microsoft's documentation.

PowerShell on Linux - The Best of Both Shells

After PowerShell is installed you can easily create scripts that will function in both a Windows and Linux environment. Note that not all cmdlets are available in the Linux version such as Get-EventLog and Get-WmiObject, which are specifically related to Windows system management.

In addition, when using PowerShell on Linux you can access cmdlets and underlying Linux commands simultaneously! In the example below the PowerShell Get-Command cmdlet is used to list all available commands, and the output is piped into the Linux grep command to search the output.

Note that while PowerShell is not case sensitive the underlying Linux commands still are, so be cautious with capitalization when mixing shell types.

Links and Resources

115 views0 comments

Recent Posts

See All