Install windows powershell script

Содержание
  1. Installing PowerShell on Windows
  2. Prerequisites
  3. Download the installer package
  4. Installing the MSI package
  5. Administrative install from the command line
  6. Registry keys created during installation
  7. Installing the ZIP package
  8. Deploying on Windows 10 IoT Enterprise
  9. Deploying on Windows 10 IoT Core
  10. Deploying on Nano Server
  11. Offline Deployment of PowerShell
  12. Online Deployment of PowerShell
  13. Install as a .NET Global tool
  14. Install PowerShell via Winget
  15. Installing from the Microsoft Store
  16. Using the MSIX package
  17. How to create a remoting endpoint
  18. Upgrading an existing installation
  19. Installation support
  20. Запуск Windows PowerShell Starting Windows PowerShell
  21. В PowerShell Core есть переименованный двоичный файл PowerShell Core has renamed binary
  22. Запуск Windows PowerShell в более ранних версиях Windows How to Start Windows PowerShell on Earlier Versions of Windows
  23. Из меню «Пуск» From the Start Menu
  24. В командной строке At the Command Prompt
  25. С правами администратора (Запуск от имени администратора) With Administrative privileges (Run as administrator)
  26. Запуск интегрированной среды сценариев Windows PowerShell в более ранних версиях Windows How to Start Windows PowerShell ISE on Earlier Releases of Windows
  27. Из меню «Пуск» From the Start Menu
  28. В командной строке At the Command Prompt
  29. С правами администратора (Запуск от имени администратора) With Administrative privileges (Run as administrator)
  30. Включение интегрированной среды сценариев Windows PowerShell в более ранних версиях Windows How to Enable Windows PowerShell ISE on Earlier Releases of Windows
  31. Включение интегрированной среды сценариев Windows PowerShell Windows PowerShell (ISE) To enable Windows PowerShell Integrated Scripting Environment (ISE)
  32. Запуск 32-разрядной версии Windows PowerShell Starting the 32-Bit Version of Windows PowerShell

Installing PowerShell on Windows

There are multiple ways to install PowerShell in Windows.

Prerequisites

The latest release of PowerShell is supported on Windows 7 SP1, Server 2008 R2, and later versions.

To enable PowerShell remoting over WSMan, the following prerequisites need to be met:

  • Install the Universal C Runtime on Windows versions predating Windows 10. It’s available via direct download or Windows Update. Fully patched systems already have this package installed.
  • Install the Windows Management Framework (WMF) 4.0 or newer on Windows 7 and Windows Server 2008 R2. For more information about WMF, see WMF Overview.

Download the installer package

To install PowerShell on Windows, download the latest install package from GitHub. You can also find the latest preview version. Scroll down to the Assets section of the Release page. The Assets section may be collapsed, so you may need to click to expand it.

Installing the MSI package

The MSI file looks like PowerShell- -win- .msi . For example:

Once downloaded, double-click the installer and follow the prompts.

The installer creates a shortcut in the Windows Start Menu.

  • By default the package is installed to $env:ProgramFiles\PowerShell\
  • You can launch PowerShell via the Start Menu or $env:ProgramFiles\PowerShell\ \pwsh.exe

PowerShell 7.1 installs to a new directory and runs side-by-side with Windows PowerShell 5.1. PowerShell 7.1 is an in-place upgrade that replaces PowerShell 6.x. or PowerShell 7.0.

  • PowerShell 7.1 is installed to $env:ProgramFiles\PowerShell\7
  • The $env:ProgramFiles\PowerShell\7 folder is added to $env:PATH
  • The $env:ProgramFiles\PowerShell\6 folder is deleted

If you need to run PowerShell 7.1 side-by-side with other versions, use the ZIP install method to install the other version to a different folder.

Administrative install from the command line

MSI packages can be installed from the command line allowing administrators to deploy packages without user interaction. The MSI package includes the following properties to control the installation options:

  • ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL — This property controls the option for adding the Open PowerShell item to the context menu in Windows Explorer.
  • ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL — This property controls the option for adding the Run with PowerShell item to the context menu in Windows Explorer.
  • ENABLE_PSREMOTING — This property controls the option for enabling PowerShell remoting during installation.
  • REGISTER_MANIFEST — This property controls the option for registering the Windows Event Logging manifest.

The following example shows how to silently install PowerShell with all the install options enabled.

For a full list of command-line options for Msiexec.exe , see Command line options.

Registry keys created during installation

Beginning in PowerShell 7.1, the MSI package creates registry keys that store the installation location and version of PowerShell. These values are located in HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\ . The value of is unique for each build type (release or preview), major version, and architecture.

Release Architecture Registry Key
7.1.x Release x86 HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\1d00683b-0f84-4db8-a64f-2f98ad42fe06
7.1.x Release x64 HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1
7.1.x Preview x86 HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\86abcfbd-1ccc-4a88-b8b2-0facfde29094
7.1.x Preview x64 HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\39243d76-adaf-42b1-94fb-16ecf83237c8

This can be used by administrators and developers to find the path to PowerShell. The values will be the same for all preview and minor version releases. The values are changed for each major release.

Installing the ZIP package

PowerShell binary ZIP archives are provided to enable advanced deployment scenarios. Download one of the following ZIP archives from the [releases][releases] page.

  • PowerShell-7.1.3-win-x64.zip
  • PowerShell-7.1.3-win-x86.zip
  • PowerShell-7.1.3-win-arm64.zip
  • PowerShell-7.1.3-win-arm32.zip

Depending on how you download the file you may need to unblock the file using the Unblock-File cmdlet. Unzip the contents to the location of your choice and run pwsh.exe from there. Unlike installing the MSI packages, installing the ZIP archive doesn’t check for prerequisites. For remoting over WSMan to work properly, ensure that you’ve met the prerequisites.

Use this method to install the ARM-based version of PowerShell on computers like the Microsoft Surface Pro X. For best results, install PowerShell to the to $env:ProgramFiles\PowerShell\7 folder.

You can use this method to install any version of PowerShell including the latest:

Deploying on Windows 10 IoT Enterprise

Windows 10 IoT Enterprise comes with Windows PowerShell, which we can use to deploy PowerShell 7.

Create PSSession to target device

Copy the ZIP package to the device

Connect to the device and expand the archive

Set up remoting to PowerShell 7

Connect to PowerShell 7 endpoint on device

Deploying on Windows 10 IoT Core

Windows 10 IoT Core adds Windows PowerShell when you include IOT_POWERSHELL feature, which we can use to deploy PowerShell 7. The steps defined above for Windows 10 IoT Enterprise can be followed for IoT Core as well.

For adding the latest PowerShell in the shipping image, use Import-PSCoreRelease command to include the package in the workarea and add OPENSRC_POWERSHELL feature to your image.

For ARM64 architecture, Windows PowerShell is not added when you include IOT_POWERSHELL. So the zip based install will not work. You will need to use Import-PSCoreRelease command to add it in the image.

Deploying on Nano Server

These instructions assume that the Nano Server is a «headless» OS that has a version of PowerShell is already running on it. For more information, see the Nano Server Image Builder documentation.

PowerShell binaries can be deployed using two different methods.

  1. Offline — Mount the Nano Server VHD and unzip the contents of the zip file to your chosen location within the mounted image.
  2. Online — Transfer the zip file over a PowerShell Session and unzip it in your chosen location.

In both cases, you need the Windows 10 x64 ZIP release package. Run the commands within an «Administrator» instance of PowerShell.

Offline Deployment of PowerShell

  1. Use your favorite zip utility to unzip the package to a directory within the mounted Nano Server image.
  2. Unmount the image and boot it.
  3. Connect to the built-in instance of Windows PowerShell.
  4. Follow the instructions to create a remoting endpoint using the «another instance technique».

Online Deployment of PowerShell

Deploy PowerShell to Nano Server using the following steps.

Connect to the built-in instance of Windows PowerShell

Copy the file to the Nano Server instance

Enter the session

Extract the ZIP file

If you want WSMan-based remoting, follow the instructions to create a remoting endpoint using the «another instance technique».

Install as a .NET Global tool

If you already have the .NET Core SDK installed, it’s easy to install PowerShell as a .NET Global tool.

The dotnet tool installer adds $env:USERPROFILE\.dotnet\tools to your $env:PATH environment variable. However, the currently running shell doesn’t have the updated $env:PATH . You can start PowerShell from a new shell by typing pwsh .

Install PowerShell via Winget

The winget command-line tool enables developers to discover, install, upgrade, remove, and configure applications on Windows 10 computers. This tool is the client interface to the Windows Package Manager service.

The winget tool is currently a preview. Not all planned functionality is available at this time. You should not use this method in a production deployment scenario. See the winget documentation for a list of system requirements and install instructions.

The following commands can be used to install PowerShell using the published winget packages:

Search for the latest version of PowerShell

Install a version of PowerShell using the —exact parameter

Installing from the Microsoft Store

PowerShell 7.1 has been published to the Microsoft Store. You can find the PowerShell release on the Microsoft Store website or in the Store application in Windows.

Benefits of the Microsoft Store package:

  • Automatic updates built right into Windows 10
  • Integrates with other software distribution mechanisms like Intune and SCCM

MSIX packages run in an application sandbox that virtualizes access to some filesystem and registry locations.

  • All registry changes under HKEY_CURRENT_USER are copied on write to a private, per-user, per-app location. Therefore, those values are not available to other applications.
  • Any system-level configuration settings stored in $PSHOME cannot be modified. This includes the WSMAN configuration. This prevents remote sessions from connecting to Store-based installs of PowerShell. User-level configurations and SSH remoting are supported.

Using the MSIX package

The preview builds of PowerShell include an MSIX package. The MSIX package is not officially supported. The package is built for testing purposes during the preview period.

To manually install the MSIX package on a Windows 10 client, download the MSIX package from our GitHub [releases][releases] page. Scroll down to the Assets section of the Release you want to install. The Assets section may be collapsed, so you may need to click to expand it.

The MSIX file looks like this — PowerShell- -win- .msix

To install the package, you must use the Add-AppxPackage cmdlet.

How to create a remoting endpoint

PowerShell supports the PowerShell Remoting Protocol (PSRP) over both WSMan and SSH. For more information, see:

Upgrading an existing installation

For best results when upgrading, you should use the same install method you used when you first installed PowerShell. Each installation method installs PowerShell in a different location. If you are not sure how PowerShell was installed, you can compare the installed location with the package information in this article. If you installed via the MSI package, that information appears in the Programs and Features Control Panel.

Installation support

Microsoft supports the installation methods in this document. There may be other methods of installation available from other sources. While those tools and methods may work, Microsoft cannot support those methods.

Запуск Windows PowerShell Starting Windows PowerShell

Windows PowerShell — это обработчик скриптов .DLL , который внедрен в несколько узлов. Windows PowerShell is a scripting engine .DLL that’s embedded into multiple hosts. Самый распространенный запускаемый узел — интерактивная командная строка powershell.exe и интерактивная среда скриптов powershell_ise.exe . The most common hosts you’ll start are the interactive command-line powershell.exe and the Interactive Scripting Environment powershell_ise.exe .

Информацию о запуске Windows PowerShell® в Windows Server® 2012 R2, Windows® 8.1, Windows Server 2012 и Windows 8 см. в статье Общие задачи управления и навигации в Windows. To start Windows PowerShell® on Windows Server® 2012 R2, Windows® 8.1, Windows Server 2012, and Windows 8, see Common Management Tasks and Navigation in Windows.

В PowerShell Core есть переименованный двоичный файл PowerShell Core has renamed binary

PowerShell Core, или PowerShell, имеет версию 6 и выше с открытым исходным кодом и использует .NET Core. PowerShell Core, referred to as PowerShell, is version 6 and higher that’s open source and uses .NET Core. Поддерживаемые версии доступны в Windows, macOS и Linux. Supported versions are available on Windows, macOS, and Linux.

Начиная с PowerShell 6 двоичный файл PowerShell был переименован в pwsh.exe для Windows и pwsh для macOS и Linux. Beginning in PowerShell 6, the PowerShell binary was renamed pwsh.exe for Windows and pwsh for macOS and Linux. Вы можете запустить предварительную версию PowerShell с помощью pwsh-preview . You can start PowerShell preview versions using pwsh-preview . Дополнительные сведения см. в разделе Новые возможности в PowerShell Core 6.0 и Сведения о pwsh. For more information, see What’s New in PowerShell Core 6.0 and About pwsh.

Чтобы найти справку по командлетам и документацию по установке для PowerShell 7, воспользуйтесь следующими ссылками: To find cmdlet reference and installation documentation for PowerShell 7, use the following links:

Документ Document Ссылка Link
Справка по командлетам Cmdlet reference Обозреватель модулей PowerShell PowerShell Module Browser
Установка в Windows Windows installation Установка PowerShell Core в Windows Installing PowerShell Core on Windows
Установка в macOS macOS installation Установка PowerShell Core в macOS Installing PowerShell Core on macOS
Установка в Linux Linux installation Установка PowerShell Core в Linux Installing PowerShell Core on Linux

Сведения о других версиях PowerShell см. в документации по использованию PowerShell. To view content for other PowerShell versions, see How to use the PowerShell documentation.

Запуск Windows PowerShell в более ранних версиях Windows How to Start Windows PowerShell on Earlier Versions of Windows

В этом разделе объясняется, как запустить Windows PowerShell и интегрированную среду скриптов Windows PowerShell (ISE) в Windows® 7, Windows Server® 2008 R2 и Windows Server® 2008. This section explains how to start Windows PowerShell and Windows PowerShell Integrated Scripting Environment (ISE) on Windows® 7, Windows Server® 2008 R2, and Windows Server® 2008. Кроме того, здесь поясняется, как включить дополнительный компонент Windows PowerShell ISE в Windows PowerShell 2.0 в ОС Windows Server® 2008 R2 и Windows Server® 2008. It also explains how to enable the optional feature for Windows PowerShell ISE in Windows PowerShell 2.0 on Windows Server® 2008 R2 and Windows Server® 2008.

Используйте любой из следующих методов для запуска установленной версии Windows PowerShell 3.0 или Windows PowerShell 4.0, где это возможно. Use any of the following methods to start the installed version of Windows PowerShell 3.0, or Windows PowerShell 4.0, where applicable.

Из меню «Пуск» From the Start Menu

  • Нажмите кнопку Пуск , введите PowerShell и выберите Windows PowerShell. Click Start , type PowerShell , and then click Windows PowerShell.
  • В меню Пуск выберите Пуск , Все программы , Стандартные , откройте папку Windows PowerShell и щелкните Windows PowerShell. From the Start menu, click Start , click All Programs , click Accessories , click the Windows PowerShell folder, and then click Windows PowerShell.

В командной строке At the Command Prompt

В cmd.exe , Windows PowerShell или интегрированной среде сценариев Windows PowerShell для запуска Windows PowerShell введите следующее: In cmd.exe , Windows PowerShell, or Windows PowerShell ISE, to start Windows PowerShell, type:

Можно также использовать параметры программы powershell.exe для настройки сеанса. You can also use the parameters of the powershell.exe program to customize the session. Дополнительные сведения см. в статье Справка по командной строке PowerShell.exe. For more information, see PowerShell.exe Command-Line Help.

С правами администратора (Запуск от имени администратора) With Administrative privileges (Run as administrator)

Нажмите кнопку Пуск , введите PowerShell , щелкните правой кнопкой мыши Windows PowerShell и выберите пункт Запуск от имени администратора. Click Start , type PowerShell , right-click Windows PowerShell , and then click Run as administrator.

Запуск интегрированной среды сценариев Windows PowerShell в более ранних версиях Windows How to Start Windows PowerShell ISE on Earlier Releases of Windows

Используйте один из следующих методов для запуска интегрированной среды сценариев Windows PowerShell. Use any of the following methods to start Windows PowerShell ISE.

Из меню «Пуск» From the Start Menu

  • Нажмите кнопку Пуск , введите Интегрированная среда сценариев и выберите Интегрированная среда сценариев Windows PowerShell. Click Start , type ISE , and then click Windows PowerShell ISE.
  • В меню Пуск выберите Пуск , Все программы , Стандартные , откройте папку Windows PowerShell и щелкните Интегрированная среда сценариев Windows PowerShell. From the Start menu, click Start , click All Programs , click Accessories , click the Windows PowerShell folder, and then click Windows PowerShell ISE.

В командной строке At the Command Prompt

В cmd.exe , Windows PowerShell или интегрированной среде сценариев Windows PowerShell для запуска Windows PowerShell введите следующее: In cmd.exe , Windows PowerShell, or Windows PowerShell ISE, to start Windows PowerShell, type:

С правами администратора (Запуск от имени администратора) With Administrative privileges (Run as administrator)

Нажмите кнопку Пуск , введите Интегрированная среда сценариев , щелкните правой кнопкой мыши Интегрированная среда сценариев Windows PowerShell и выберите пункт Запуск от имени администратора. Click Start , type ISE , right-click Windows PowerShell ISE , and then click Run as administrator.

Включение интегрированной среды сценариев Windows PowerShell в более ранних версиях Windows How to Enable Windows PowerShell ISE on Earlier Releases of Windows

При использовании Windows PowerShell 4.0 и Windows PowerShell 3.0 интегрированная среда сценариев Windows PowerShell по умолчанию включена во всех версиях Windows. In Windows PowerShell 4.0 and Windows PowerShell 3.0, Windows PowerShell ISE is enabled by default on all versions of Windows. Если она еще не включена, Windows Management Framework 4.0 или Windows Management Framework 3.0 включает ее. If it isn’t already enabled, Windows Management Framework 4.0 or Windows Management Framework 3.0 enables it.

При использовании Windows PowerShell 2.0 интегрированная среда сценариев Windows PowerShell по умолчанию включена в Windows 7. In Windows PowerShell 2.0, Windows PowerShell ISE is enabled by default on Windows 7. В Windows Server 2008 R2 и Windows Server 2008 эта функция является дополнительной. However, on Windows Server 2008 R2 and Windows Server 2008, it’s an optional feature.

Чтобы включить интегрированную среду сценариев Windows PowerShell для Windows PowerShell 2.0 в Windows Server 2008 R2 или Windows Server 2008, выполните указанные ниже действия. To enable Windows PowerShell ISE in Windows PowerShell 2.0 on Windows Server 2008 R2 or Windows Server 2008, use the following procedure.

Включение интегрированной среды сценариев Windows PowerShell Windows PowerShell (ISE) To enable Windows PowerShell Integrated Scripting Environment (ISE)

  1. Запустите диспетчер серверов. Start Server Manager.
  2. Щелкните Компоненты и выберите Добавить компоненты. Click Features and then click Add Features.
  3. В меню «Выберите компоненты» щелкните интегрированную среду сценариев Windows PowerShell. In Select Features, click Windows PowerShell Integrated Scripting Environment (ISE).

Запуск 32-разрядной версии Windows PowerShell Starting the 32-Bit Version of Windows PowerShell

При установке Windows PowerShell на 64-разрядном компьютере в дополнение к 64-разрядной версии устанавливается Windows PowerShell (x86) — 32-разрядная версия Windows PowerShell. When you install Windows PowerShell on a 64-bit computer, Windows PowerShell (x86) , a 32-bit version of Windows PowerShell is installed in addition to the 64-bit version. При открытии Windows PowerShell по умолчанию запускается 64-разрядная версия. When you run Windows PowerShell, the 64-bit version runs by default.

Однако в некоторых случаях нужно запустить Windows PowerShell (x86) , например при использовании модуля, которому требуется 32-разрядная версия, или при удаленном подключении к 32-разрядному компьютеру. However, you might occasionally need to run Windows PowerShell (x86) , such as when you’re using a module that requires the 32-bit version or when you’re connecting remotely to a 32-bit computer.

Для запуска 32-разрядной версии Windows PowerShell воспользуйтесь любой из следующих процедур. To start a 32-bit version of Windows PowerShell, use any of the following procedures.

Читайте также:  Run grub from windows
Оцените статью