Share via


About Windows PowerShell

The Microsoft® Windows® PowerShell provides a language, a runtime, commands, and a replaceable command-line shell. Together, these components and their extensions are used to automate administration tasks.

Windows PowerShell Language

The Windows PowerShell language provides scripting functions and mechanisms to invoke commands or other executables. Commands can be executed either singly (get-process), in a pipeline (get-process notepad | stop-process), or by scripts.

Windows PowerShell Runtime

The Windows PowerShell runtime provides the capability to do the following:

  • Store and retrieve Windows PowerShell language variables.

  • Access and host an application’s user interface capabilities.

  • Access .NET Objects and COM Objects with their associated properties and methods.

  • Access various utility classes.

For more information about the Windows PowerShell runtime, see Windows PowerShell Runtime.

Windows PowerShell Cmdlets

A cmdlet (pronounced "command-let") is the smallest unit of functionality in Windows PowerShell, and it is directly analogous to the built-in commands in other shells such as KSH or BASH. In a traditional shell such as Cmd.exe or KSH, commands are generally separate executable programs that range from the simple (Attrib.exe) to the complex (Netsh.exe) as well as a number of commands that are "built-in" to the shell (such as dir command in Cmd.exe and cd command in ksh). With Windows PowerShell, most commands are simple and small, hence the term "command-let" or cmdlet.

Windows PowerShell includes a number of cmdlets for manipulating the Microsoft Windows system. When necessary, developers can also add custom cmdlets to Windows PowerShell. Be aware that other commands (.exe, .bat, .cmd files) will execute in Windows PowerShell as well.

Note

The classes of these supplied cmdlets are referenced in this SDK under the Microsoft.PowerShell.Commands namespace.

The benefits of this model for commands are that a cmdlet factors out common functionality, such as parsing and validation of data, so that the following can occur:

  • The cmdlet developer can write simpler, narrowly focused .NET methods.

  • The user experience is consistent and complete.

For more information about cmdlets, see Windows PowerShell Cmdlets.

Windows PowerShell Providers

Windows PowerShell also provides a highly optimized mechanism (called a Windows PowerShell provider, or simply "provider") that exposes a set of common cmdlets that can navigate any data store. When a developer implements a Windows PowerShell provider, the Windows PowerShell provider provider infrastructure in Windows PowerShell automatically provides this set of common cmdlets access to that store (such as the file system or the registry).

For more information about Windows PowerShell providers, see Windows PowerShell Providers.

Windows PowerShell Hosting Applications

By default, Windows PowerShell includes a console application, called Windows PowerShell.exe, that interacts with the user and hosts the Windows PowerShell runtime.

However, an application can choose to create an instance of the Windows PowerShell runtime (called a “runspace”) and run commands and scripts directly. Such an application is called a “hosting application” (shortened to application). An application can choose to do the following:

  • Provide no ability for the invoked pipelines to communicate directly with the application’s user. In these cases, the application simply runs the desired pipelines and retrieves the results directly.

  • Provide the default Windows PowerShell host to handle user interaction.

  • Replace the Windows PowerShell host to provide commands and scripts for direct user interaction, such as prompting for a parameter. If an application chooses to do this, it implements a “PSHost”.

Windows PowerShell Namespaces

Windows PowerShell provides several namespaces that define the types that can be used for developing cmdlets. For a brief description of these namespaces, see Windows PowerShell Namespaces.

See Also

Concepts

Windows PowerShell SDK

Other Resources

Windows PowerShell Programmer's Guide

Footer image