How to install windows powershell

Installing the Windows PowerShell SDK

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

The following topic describes how to install the PowerShell SDK on different versions of Windows.

Installing Windows PowerShell 3.0 SDK for Windows 8 and Windows Server 2012

Windows PowerShell 3.0 is automatically installed with Windows 8 and Windows Server 2012. In addition, you can download and install the reference assemblies for Windows PowerShell 3.0 as part of the Windows 8 SDK. These assemblies allow you to write cmdlets, providers, and host programs for Windows PowerShell 3.0. When you install the Windows SDK for Windows 8, the Windows PowerShell assemblies are automatically installed in the reference assembly folder, in \Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0 . For more information, see the Windows 8 SDK download site. Windows PowerShell code samples are also available in the powershell-sdk-samples repository.

Installing Windows PowerShell 3.0 SDK for Windows 7 and Windows Server 2008 R2

Windows 7 and Windows Server 2008 R2 automatically have PowerShell 2.0 installed. In addition, you can install PowerShell 3.0 on these systems. You can also install the Windows 8 SDK on Windows 7 and Windows Server 2008 R2 as described above.

Installing Windows PowerShell 2.0 SDK for Windows 7, Vista, XP, Server 2003, and Server 2008

The Windows PowerShell 2.0 SDK provides the reference assemblies needed to write cmdlets, providers, and hosting applications, and it provides C# sample code that can be used as the starting point when you begin writing code. You can download the code samples from https://www.microsoft.com/download/details.aspx?id=2560.

Reference assemblies

Reference assemblies are installed in the following location by default: c:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\V1.0 .

Code that is compiled against the Windows PowerShell 2.0 assemblies cannot be loaded into Windows PowerShell 1.0 installations. However, code that is compiled against the Windows PowerShell 1.0 assemblies can be loaded into Windows PowerShell 2.0 installations.

Samples

Code samples are installed in the following location by default: C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\sysmgmt\WindowsPowerShell\ . The following sections provide a brief description of what each sample does.

Cmdlet samples

  • GetProcessSample01 — Shows how to write a simple cmdlet that gets all the processes on the local computer.
  • GetProcessSample02 — Shows how to add parameters to the cmdlet. The cmdlet takes one or more process names and returns the matching processes.
  • GetProcessSample03 — Shows how to add parameters that accept input from the pipeline.
  • GetProcessSample04 — Shows how to handle non-terminating errors.
  • GetProcessSample05 — Shows how to display a list of specified processes.
  • SelectObject — Shows how to write a filter to select only certain objects.
  • SelectString — Shows how to search files for specified patterns.
  • StopProcessSample01 — Shows how to implement a PassThru parameter, and how to request user feedback by calls to the ShouldProcess and ShouldContinue methods. Users specify the PassThru parameter when they want to force the cmdlet to return an object,
  • StopProcessSample02 — Shows how to stop a specific process.
  • StopProcessSample03 — Shows how to declare aliases for parameters and how to support wildcards.
  • StopProcessSample04 — Shows how to declare parameter sets, the object that the cmdlet takes as input, and how to specify the default parameter set to use.
Читайте также:  Установить appx windows 10 ltsb

Remoting samples

  • RemoteRunspace01 — Shows how to create a remote runspace that is used to establish a remote connection.
  • RemoteRunspacePool01 — Shows how to construct a remote runspace pool and how to run multiple commands concurrently by using this pool.
  • Serialization01 — Shows how to look at an existing .NET class and make sure that information from selected public properties of this class is preserved across serialization/deserialization.
  • Serialization02 — Shows how to look at an existing .NET class and make sure that information from instance of this class is preserved across serialization/deserialization when the information is not available in public properties of the class.
  • Serialization03 — Shows how to look at an existing .NET class and make sure that instances of this class and of derived classes are deserialized (rehydrated) into live .NET objects.

Event samples

  • Event01 — Shows how to create a cmdlet for event registration by deriving from ObjectEventRegistrationBase.
  • Event02 — Shows how to shows how to receive notifications of Windows PowerShell events that are generated on remote computers. It uses the PSEventReceived event exposed through the Runspace class.

Hosting application samples

  • Runspace01 — Shows how to use the PowerShell class to run the Get-Process cmdlet synchronously. The Get-Process cmdlet returns Process objects for each process running on the local computer.
  • Runspace02 — Shows how to use the PowerShell class to run the Get-Process and Sort-Object cmdlets synchronously. The Get-Process cmdlet returns Process objects for each process running on the local computer, and the Sort-Object sorts the objects based on their Id property. The results of these commands is displayed by using a DataGridView control.
  • Runspace03 — Shows how to use the PowerShell class to run a script synchronously, and how to handle non-terminating errors. The script receives a list of process names and then retrieves those processes. The results of the script, including any non-terminating errors that were generated when running the script, are displayed in a console window.
  • Runspace04 — Shows how to use the PowerShell class to run commands, and how to catch terminating errors that are thrown when running the commands. Two commands are run, and the last command is passed a parameter argument that is not valid. As a result, no objects are returned and a terminating error is thrown.
  • Runspace05 — Shows how to add a snap-in to an InitialSessionState object so that the cmdlet of the snap-in is available when the runspace is opened. The snap-in provides a Get-Proc cmdlet (defined by the GetProcessSample01 Sample) that is run synchronously using a PowerShell object.
  • Runspace06 — Shows how to add a module to an InitialSessionState object so that the module is loaded when the runspace is opened. The module provides a Get-Proc cmdlet (defined by the GetProcessSample02 Sample) that is run synchronously using a PowerShell object.
  • Runspace07 — Shows how to create a runspace, and then use that runspace to run two cmdlets synchronously using a PowerShell object.
  • Runspace08 — Shows how to add commands and arguments to the pipeline of a PowerShell object and how to run the commands synchronously.
  • Runspace09 — Shows how to add a script to the pipeline of a PowerShell object and how to run the script asynchronously. Events are used to handle the output of the script.
  • Runspace10 — Shows how to create a default initial session state, how to add a cmdlet to the InitialSessionState, how to create a runspace that uses the initial session state, and how to run the command using a PowerShell object.
  • Runspace11 — Shows how to use the ProxyCommand class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command.
  • PowerShell01 — Shows how to create a constrained runspace using an InitialSessionState object.
  • PowerShell02 — Shows how to use a runspace pool to run multiple commands concurrently.
Читайте также:  Make arch arm cross compile arm linux gnueabihf

Host samples

  • Host01 — Shows how to implement a host application that uses a custom host. In this sample a runspace is created that uses the custom host, and then the PowerShell API is used to run a script that calls exit . The host application then looks at the output of the script and prints out the results.
  • Host02 — Shows how to write a host application that uses the Windows PowerShell runtime along with a custom host implementation. The host application sets the host culture to German, runs the Get-Process cmdlet and displays the results as you would see them by using pwrsh.exe, and then prints out the current data and time in German.
  • Host03 — Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console.
  • Host04 — Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports displaying prompts that allow the user to specify multiple choices.
  • Host05 — Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports calls to remote computers by using the Enter-PsSession and Exit-PsSession cmdlets.
  • Host06 — Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. In addition, this sample uses the Tokenizer APIs to specify the color of the text that is entered by the user.

Provider samples

AccessDBProviderSample01 — Shows how to declare a provider class that derives directly from the CmdletProvider class. It is included here only for completeness.

AccessDBProviderSample02 — Shows how to overwrite the NewDrive and RemoveDrive methods to support calls to the New-PSDrive and Remove-PSDrive cmdlets. The provider class in this sample derives from the DriveCmdletProvider class.

AccessDBProviderSample03 — Shows how to overwrite the GetItem and SetItem methods to support calls to the Get-Item and Set-Item cmdlets. The provider class in this sample derives from the ItemCmdletProvider class.

AccessDBProviderSample04 — Shows how to overwrite container methods to support calls to the Copy-Item , Get-ChildItem , New-Item , and Remove-Item cmdlets. These methods should be implemented when the data store contains items that are containers. A container is a group of child items under a common parent item. The provider class in this sample derives from the ItemCmdletProvider class.

AccessDBProviderSample05 — Shows how to overwrite container methods to support calls to the Move-Item and Join-Path cmdlets. These methods should be implemented when the user needs to move items within a container and if the data store contains nested containers. The provider class in this sample derives from the NavigationCmdletProvider class.

AccessDBProviderSample06 — Shows how to overwrite content methods to support calls to the Clear-Content , Get-Content , and Set-Content cmdlets. These methods should be implemented when the user needs to manage the content of the items in the data store. The provider class in this sample derives from the NavigationCmdletProvider class, and it implements the IContentCmdletProvider interface.

Starting Windows PowerShell

Windows PowerShell is a scripting engine .DLL that’s embedded into multiple hosts. The most common hosts you’ll start are the interactive command-line powershell.exe and the Interactive Scripting Environment powershell_ise.exe .

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.

Читайте также:  Daemon tools lite для windows 10 ключик активации

PowerShell Core has renamed binary

PowerShell Core, referred to as PowerShell, is version 6 and higher that’s open source and uses .NET Core. Supported versions are available on Windows, macOS, and Linux.

Beginning in PowerShell 6, the PowerShell binary was renamed pwsh.exe for Windows and pwsh for macOS and Linux. You can start PowerShell preview versions using pwsh-preview . For more information, see What’s New in PowerShell Core 6.0 and About pwsh.

To find cmdlet reference and installation documentation for PowerShell 7, use the following links:

Document Link
Cmdlet reference PowerShell Module Browser
Windows installation Installing PowerShell Core on Windows
macOS installation Installing PowerShell Core on macOS
Linux installation Installing PowerShell Core on Linux

To view content for other PowerShell versions, see How to use the PowerShell documentation.

How to Start Windows PowerShell on Earlier Versions of Windows

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. 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.

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

  • Click Start, type PowerShell, and then click 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

In cmd.exe, Windows PowerShell, or Windows PowerShell ISE, to start Windows PowerShell, type:

You can also use the parameters of the powershell.exe program to customize the session. For more information, see PowerShell.exe Command-Line Help.

With Administrative privileges (Run as administrator)

Click Start, type PowerShell, right-click Windows PowerShell, and then click Run as administrator.

How to Start Windows PowerShell ISE on Earlier Releases of Windows

Use any of the following methods to start Windows PowerShell ISE.

From the Start Menu

  • Click Start, type ISE, and then click Windows PowerShell ISE.
  • 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

In cmd.exe , Windows PowerShell, or Windows PowerShell ISE, to start Windows PowerShell, type:

With Administrative privileges (Run as administrator)

Click Start, type ISE, right-click Windows PowerShell ISE, and then click Run as administrator.

How to Enable Windows PowerShell ISE on Earlier Releases of Windows

In Windows PowerShell 4.0 and Windows PowerShell 3.0, Windows PowerShell ISE is enabled by default on all versions of Windows. If it isn’t already enabled, Windows Management Framework 4.0 or Windows Management Framework 3.0 enables it.

In Windows PowerShell 2.0, Windows PowerShell ISE is enabled by default on Windows 7. However, on Windows Server 2008 R2 and Windows Server 2008, it’s an optional feature.

To enable Windows PowerShell ISE in Windows PowerShell 2.0 on Windows Server 2008 R2 or Windows Server 2008, use the following procedure.

To enable Windows PowerShell Integrated Scripting Environment (ISE)

  1. Start Server Manager.
  2. Click Features and then click Add Features.
  3. In Select Features, click Windows PowerShell Integrated Scripting Environment (ISE).

Starting the 32-Bit Version of 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. When you run Windows PowerShell, the 64-bit version runs by default.

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.

To start a 32-bit version of Windows PowerShell, use any of the following procedures.

Оцените статью