How to Install and Use PowerShell on Ubuntu Linux

PowerShell, once exclusive to the Windows ecosystem, is now a cross-platform automation and configuration management framework. It allows you to use its object-oriented pipeline and powerful cmdlets on Linux systems, providing a bridge between Windows and Linux administration tasks.

Why Use PowerShell on Linux?

The first thing you might ask is why should I bother using POSH on Linux? There are in fact several reasons why you may consider PowerShell on Linux:

  1. Unified Toolset: Manage both Windows and Linux systems using the same scripting language and cmdlets. Traditionally, managing mixed environments (Linux and Windows) meant juggling disparate tools and skillsets. PowerShell on Linux bridges this gap, offering a unified approach that simplifies administration and reduces the learning curve for those familiar with PowerShell.
  2. Automation & Configuration Management: Leverage PowerShell’s capabilities for complex automation tasks and infrastructure configuration. Linux boasts a rich ecosystem of automation tools, but PowerShell brings its unique strengths to the table. Its object-oriented pipeline, powerful cmdlets, and integration with .NET provide new possibilities for sophisticated automation and configuration management tasks on Linux.
  3. .NET Integration: Seamlessly interact with the .NET ecosystem and leverage its libraries. While Linux has its share of frameworks, PowerShell’s seamless .NET integration opens the door to leveraging a vast collection of libraries and tools built on the .NET platform, further extending what’s achievable on Linux.
  4. Cross-Platform Compatibility: Write scripts that run consistently on Windows, Linux, and macOS. For those working across multiple platforms, PowerShell on Linux eliminates the need for platform-specific scripting. This consistency saves time, reduces errors, and promotes code reusability, whether you’re managing servers, deploying applications, or orchestrating complex tasks.

It’s about breaking down barriers and providing a more versatile and powerful toolkit for tackling the challenges of modern IT environments.

Technical Guide: Installing and Using PowerShell on Ubuntu

What do you need?

  • Ubuntu Linux: Ensure you have a supported Ubuntu version (e.g., 20.04 LTS or later).
  • Superuser Access: You’ll need sudo privileges to install packages and configure PowerShell.

Step 1 – Installation

Update the Package List that Keeps your system up-to-date with the latest package information. Install the dependencies that PowerShell relies on certain packages for its operation, then Import the Microsoft Repository Key to ensure the authenticity of packages from Microsoft’s repository.

Finally, Install PowerShell and Verify the Installation

sudo apt update
sudo apt install -y wget apt-transport-https software-properties-common
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y powershell
pwsh --version

Step 2 – Start Using PowerShell (POSH)

Alright, you’ve got PowerShell installed – now let’s put it to work!

To kick things off, launch an interactive PowerShell session right from your terminal. Just type pwsh and hit enter. You’ll see the familiar PowerShell prompt, ready for action.

Its that simple, you are now ready to starting using PowerShell on Linux.

Elsewhere On TurboGeek:  Arcserve Backup & Disaster Recovery: Bare Metal Restore Made Easy

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »