Tag: PowerShell Version

  • How to Install PowerShell on Ubuntu 20.04

    How to Install PowerShell on Ubuntu 20.04

    This post is a guide on installing PowerShell on Ubuntu 20.04.

    The Ubuntu Linux distribution being used in this demo is running as a Windows Subsystem for Linux (WSL) instance. I have not yet encountered issues with the PowerShell, Ubuntu and WSL cocktail.

    Be sure to check out Microsoft Documentation, Installing PowerShell on Linux (Ubuntu) for up-to-date information, particularly for PS Linux version compatibility and end-of-support dates.

    The following is covered in this demo:
    # Install PowerShell on Ubuntu
    # Open PowerShell on Ubuntu

    Install PowerShell on Ubuntu

    As mentioned above, I’m installing PowerShell on Ubuntu WSL for this demo. Why would you want to emulate Linux on Windows to then install PowerShell? Because it’s a great cross-platform programming language? The reason I’m performing this on WSL is that the Windows Subsystem is great for spinning up a test Ubuntu instance.

    To install PowerShell on Ubuntu 20.04, run through the Linux commands below. This is as described in the Install via Package Repository Microsoft documentation page, be sure to check that out for any updated information.

    # Update the list of packages
    sudo apt-get update
    
    # Install pre-requisite packages.
    sudo apt-get install -y wget apt-transport-https software-properties-common
    
    # Download the Microsoft repository GPG keys
    wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
    
    # Register the Microsoft repository GPG keys
    sudo dpkg -i packages-microsoft-prod.deb
    
    # Update the list of packages after we added packages.microsoft.com
    sudo apt-get update
    
    # Install PowerShell on Ubuntu
    sudo apt-get install -y powershell
    Ubuntu Install PowerShell

    The above PowerShell installation should only take a minute or so to complete, including the Advanced Package Tool (apt) updates.

    Open PowerShell on Ubuntu

    Now that we have PowerShell installed on this Ubuntu WSL instance, we can check the running PowerShell version and open PowerShell in Ubuntu.

    The default Alias for PowerShell is pwsh. You can find information about pwsh and pwsh parameters within the MS Docs as linked.

    # Check PowerShell Version on Ubuntu
    pwsh -v
    
    # Start PowerShell on Ubuntu
    pwsh
    
    Run PowerShell Ubuntu

    The above shows the running PowerShell version of 7.2.7, and we are entering PowerShell using the pwsh command.

    We can also run $PSVersionTable while in pwsh to check the PowerShell version in Ubuntu, which will show more OS and system information.

    Get PowerShell Version Ubuntu

    I hope this has been a helpful informational guide on installing PowerShell on Ubuntu. If you are interested in running Ubuntu on Windows, check out my other post – How To Install Windows Subsystem for Linux (WSL).

  • How to Check PowerShell Version

    How to Check PowerShell Version

    This post is a guide on how to check your PowerShell version on a Windows computer. I’m using $PSVersionTable to get this info.

    It’s important to keep all software as up-to-date as possible, we all know it. Being on the latest PowerShell version is especially required if you are utilising the latest features/cmdlets. For example, you might one day attempt to copy and run a script, and realise that it contains a command that is not recognised on a lower version of PowerShell.

    To check your PowerShell version, it’s as simple as running PSVersionTable on its own.

    -- Check PowerShell Version
    $PSVersionTable
    PSVersionTable

    I’m running version 5.1.19041 of Windows PowerShell here.

    At the time of writing, version 5.1 is the latest Windows PowerShell version, but not the latest PowerShell version available to us. To get version 7, we can download and install it as per MS Docs: Installing PowerShell on Windows.

    Before looking at rolling out upgrades across several Windows hosts, we should look at the current Supported PowerShell Versions for Windows compatibility table from Microsoft.

    That’s it for now on this one. Cheers again.