How to Install PowerShell Core: A Quick Guide

Discover the easy way to install PowerShell Core and unleash powerful scripting capabilities. Follow our step-by-step guide for a smooth setup.
How to Install PowerShell Core: A Quick Guide

To install PowerShell Core, simply download the installer from the official Microsoft repository and execute it, or use the command below for a quick installation via a package manager.

# For Windows using the command line
winget install --id Microsoft.Powershell --source winget

# For macOS using Homebrew
brew install --cask powershell

# For Linux (Debian-based) using APT
sudo apt-get install -y powershell

What is PowerShell Core?

Definition

PowerShell Core is a cross-platform version of PowerShell built on .NET Core, allowing it to run not just on Windows but also on macOS and various Linux distributions. It is significantly different from Windows PowerShell, which was exclusively designed for the Windows operating system. This modern iteration is more versatile and suitable for a broader range of scripting and automation tasks.

Key Features

PowerShell Core brings a suite of features that lend it an edge in automation and management:

  • Cross-platform compatibility: PowerShell Core can be utilized across multiple operating systems, making it an excellent choice for users who work in diverse environments.
  • Open-source nature: Being open source, PowerShell Core is continuously improved by a community of developers, ensuring it remains cutting-edge and effective.
  • Modern, extensible design: Its design allows users to extend functionalities easily, integrating new modules that enhance its capabilities.
  • Built-in support for REST APIs and JSON: PowerShell Core facilitates the manipulation of RESTful APIs and JSON data structures seamlessly.
Mastering the Art of Install PowerShell Modules
Mastering the Art of Install PowerShell Modules

Prerequisites for Installation

System Requirements

Before installing PowerShell Core, ensure that your system meets the following requirements:

  • Supported operating systems: PowerShell Core can be installed on Windows, macOS, and various distributions of Linux such as Ubuntu and CentOS.
  • Hardware specifications: While specific hardware requirements may differ between operating systems, having a modern system with at least 4GB of RAM is advisable.
  • Necessary permissions for installation: Administrative rights are required to install PowerShell Core, especially on Windows-based systems.

Tools and Resources

Familiarize yourself with tools that will facilitate the installation:

  • Windows Package Manager: A convenient method to install software on Windows.
  • Mac Homebrew: A popular package manager for macOS.
  • Linux package managers like apt, yum, or dnf, depending on your Linux distribution.
Uninstall PowerShell Module: A Simple Step-by-Step Guide
Uninstall PowerShell Module: A Simple Step-by-Step Guide

Installation Steps for PowerShell Core

Installing on Windows

Using Windows Installer

To install PowerShell Core using the Windows Installer:

  1. Download the latest release from the official PowerShell GitHub repository.
  2. Once downloaded, execute the installer by running:
Start-Process msiexec.exe -ArgumentList '/i PowerShell-<version>-win-x64.msi /quiet'

This command runs the installer silently, meaning it won't prompt you for input during the installation process.

Using Windows Package Manager

If you prefer a quicker approach, you can use the Windows Package Manager. Open PowerShell with administrative privileges and execute the following command:

winget install Microsoft.PowerShell

This command will automatically download and install the latest version of PowerShell Core.

Installing on macOS

Using Homebrew

If you are using macOS, the easiest way to install PowerShell Core is through Homebrew. First, ensure you have Homebrew installed, then run:

brew install --cask powershell

This command installs PowerShell Core, and you can start it by typing pwsh in your terminal.

Using Direct Download

Alternatively, you can download the .pkg file directly from the PowerShell GitHub releases page. After downloading, simply double-click the .pkg file and follow the installation instructions.

Installing on Linux

For Ubuntu/Debian

To install PowerShell Core on Ubuntu or Debian, follow these steps:

  1. Configure the Microsoft repository and install GPG keys:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
  1. Next, add the PowerShell repository to your list of sources:
echo "deb [arch=amd64] https://packages.microsoft.com/repos/ubuntu/ focal main" | sudo tee /etc/apt/sources.list.d/microsoft.list
  1. Finally, update the package list and install PowerShell:
sudo apt-get update
sudo apt-get install -y powershell

For CentOS/Fedora

For CentOS or Fedora users, you can install PowerShell Core with the following commands:

sudo dnf install https://packages.microsoft.com/config/rhel/7/prod.repo
sudo dnf install powershell
Brew Install PowerShell: A Quick Start Guide
Brew Install PowerShell: A Quick Start Guide

Verifying the Installation

Launching PowerShell Core

To verify that PowerShell Core has been successfully installed, open your command line interface and type:

pwsh

This command may vary based on your operating system, but pwsh is the command to enter PowerShell Core.

Confirming the Installation

You should check the version of PowerShell Core to ensure it's installed correctly. Run:

$PSVersionTable.PSVersion

This will display the current version of PowerShell running on your machine. If you see a version number you expect, you've successfully installed PowerShell Core!

Function PowerShell Return: A Quick Guide to Outputs
Function PowerShell Return: A Quick Guide to Outputs

Common Issues and Troubleshooting

Installation Errors

While installing PowerShell Core, you might encounter some common errors. If the installation fails, check the installation logs, which can provide specific error messages that point to the problem. Ensure your system meets all prerequisites and that you have administrative rights.

Compatibility Issues

If you are attempting to run PowerShell Core on an older or unsupported operating system, you may run into compatibility issues. In such cases, validate that all dependencies are met and that you are using the correct package manager commands for your system.

Restart PowerShell: A Quick How-To Guide
Restart PowerShell: A Quick How-To Guide

Upgrading PowerShell Core

Importance of Keeping Up to Date

Regularly upgrading PowerShell Core is crucial for taking advantage of new features, improvements, and security patches. Each new version comes with enhancements that can significantly streamline your automation tasks.

Upgrade Commands for Different Platforms

To upgrade PowerShell Core, execute the appropriate commands based on your operating system.

  • Windows: Use the Windows Package Manager:
winget upgrade Microsoft.PowerShell
  • macOS: Upgrade using Homebrew:
brew upgrade --cask powershell
  • Linux: Use the respective package manager commands to upgrade:

For Ubuntu/Debian:

sudo apt-get update
sudo apt-get install --only-upgrade powershell

For CentOS/Fedora:

sudo dnf upgrade powershell
WinSCP PowerShell Made Easy: A Quick Guide
WinSCP PowerShell Made Easy: A Quick Guide

Conclusion

PowerShell Core offers a powerful scripting environment that is beneficial for both beginners and advanced users in automating tasks across different platforms. By following this comprehensive guide to install PowerShell Core, you are now equipped to leverage its capabilities effectively. Dive into scripting and automation, and consider joining our community for more insightful guides and resources on mastering PowerShell.

OpenSSL PowerShell: Unlocking Encryption with Ease
OpenSSL PowerShell: Unlocking Encryption with Ease

Additional Resources

For those looking to further explore PowerShell Core, refer to the official PowerShell documentation, community forums, and various online tutorials to enhance your learning experience.

Related posts

featured
May 14, 2024

Stop PowerShell Script: A Simple Guide to Terminate Safely

featured
May 16, 2024

Adsync PowerShell Commands: A Quick Guide

featured
Mar 28, 2024

Mastering Credentials in PowerShell: A Quick Guide

featured
Feb 7, 2024

Filter PowerShell Output: A Quick Guide to Mastery

featured
Jul 9, 2024

Mastering Remote PowerShell Port: A Quick Guide

featured
May 27, 2024

How to Disable PowerShell 2.0 Effectively

featured
Jan 8, 2024

Mastering PowerShell Curl: A Simple Guide

featured
Jan 8, 2024

PowerShell Replace: Mastering Text Substitution Effortlessly