Command to install new version of powershell

To install a new version of PowerShell on Windows, you can follow these steps:

Method 1: Using the Microsoft Store (Windows 10 and later)

  1. Open the Microsoft Store app.
  2. Search for "PowerShell" in the search bar.
  3. Click on the "PowerShell" result to open its page.
  4. Click the "Install" button to download and install the latest version of PowerShell.

Method 2: Using the Windows Update (Windows 10 and later)

  1. Go to Settings > Update & Security > Windows Update.
  2. Check for updates and install any available updates.
  3. PowerShell should be updated to the latest version as part of the Windows Update process.

Method 3: Using the PowerShell Installer (Windows 7 and later)

  1. Download the PowerShell installer from the official Microsoft website: https://aka.ms/pscore
  2. Run the installer and follow the prompts to install the latest version of PowerShell.

Method 4: Using the PowerShell (Latest) package from the Microsoft Package Manager (Windows 10 and later)

  1. Open the Microsoft Package Manager (also known as winget) by searching for it in the Start menu.
  2. Type winget install PowerShell and press Enter to install the latest version of PowerShell.

Note: If you are using PowerShell 7 or later, you can also use the winget install PowerShell/7 command to install a specific version of PowerShell.

After installing a new version of PowerShell, you may need to restart your system or run the following command to update the PowerShell version:

Get-ExecutionPolicy -List

This command will list the available PowerShell versions on your system. You can then use the Set-ExecutionPolicy cmdlet to set the default PowerShell version. For example:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Default

This will set the default PowerShell version to the latest version installed on your system.