Установка PowerShell

Проверка версии

$PSVersionTable

Name Value ---- ----- PSVersion 5.1.19041.2364 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.2364 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Установка PowerShell

Может пригодиться для обновления до более свежей версии.

С помощью winget . Сперва рекомендуется проверить доступные версии

winget search Microsoft.PowerShell

The `msstore` source requires that you view the following agreements before using. Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US"). Do you agree to all the source agreements terms? [Y] Yes [N] No: Y Name Id Version Source ------------------------------------------------------- PowerShell Microsoft.PowerShell 7.3.3.0 winget PowerShell Microsoft.PowerShell.Preview 7.4.1.0 winget

Непосредственно установка

winget install --id Microsoft.Powershell --source winget

Found PowerShell [Microsoft.PowerShell] Version 7.3.3.0 This application is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.3.3/PowerShell-7.3.3-win-x64.msi ██████████████████████████████ 101 MB / 101 MB Successfully verified installer hash Starting package install... Successfully installed

PowerShell 7 установится не на замену обычному Windows PowerShell, а как дополнительный софт.

Чтобы зайти в него нужно ввести в поиск PowerShell 7

Проверка версии, обычно не нужна, так как версия показана перед первым приглашением командной строки. Тем не менее можно выполнить стандартную команду

$PSVersionTable

Name Value ---- ----- PSVersion 7.3.3 PSEdition Core GitCommitId 7.3.3 OS Microsoft Windows 10.0.19045 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

Установка PowerShell 5

Пример установки Windows PowerShell 5 на Windows 7

$PSVersionTable

Name Value ---- ----- CLRVersion 2.0.50727.879 BuildVersion 6.1.7601.1751 PSVersion 2.0 WSManStackVersion 2.0 PSCompatibleVersions {1.0, 2.0} SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1

Нужно скачать и установить .NET от 4.5.2 до 4.8 (но не 4.8.1) microsoft.com

А также Windows Management Framework 5.1 microsoft.com

$PSVersionTable

Name Value ---- ----- PSVersion 5.1.14409.1 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, BuildVersion 10.0.14409. CLRVersion 4.0.30319.4 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Переключение между 5 и 7

Если у вас уже установлены и Windows PowerShell 5 и Powershell 7 между ними можно переключаться внутри одного окна.

Команда pwsh переключает в седьмую версию. Команда powershell переключает в пятую версию

Рассмотрим пример переключения из пятой версии в седьмую и обратно. Для проверки успешности переключения используем $PSVersionTable

$PSVersionTable

Name Value ---- ----- PSVersion 5.1.19041.6575 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.6575 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

pwsh

PowerShell 7.5.4

$PSVersionTable

Name Value ---- ----- PSVersion 7.5.4 PSEdition Core GitCommitId 7.5.4 OS Microsoft Windows 10.0.19045 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

powershell

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6

$PSVersionTable

Name Value ---- ----- PSVersion 5.1.19041.6575 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.6575 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Автор статьи: Андрей Олегович