다음을 통해 공유


Windows PowerShell

 

Introduction

Windows PowerShell includes a scripting language and command shell created by Microsoft to provide easy, powerful and standard instrumentation for managing and automating Windows systems and products. Most common usage methods of PowerShell is interactive console (powershell.exe) and script files (with extension of .ps1, that is also usually executed by powershell.exe). Main features of PowerShell are: .Net integration, object pipeline, easy access to many management domains (WMI, ADSI, COM, .NET etc.) and standartization that brings easy discovery and quick learning of new features after you know base functionality. PowerShell uses special commands called cmdlets (pronounced 'command-lets') that can use .Net objects in input and output. PowerShell can also use legacy command line utilities.
To provide access to hierarchical structures like file system, registry, certificate storage and so on, PowerShell uses "providers" that expose this structures in a file-system like way. For example you can use same commands and approach to change directory into file folder or registry key, etc. 
External applications can host PowerShell as to use it as automation engine, and even build a graphical user interface above it (for example Exchange, VMM). This allows new approach to automating applications: you can use graphical interface and wizards in applications to perform actions, then get script for that actions, modify it and use for automation.

Windows PowerShell support for Microsoft Server products are enforced with Common Engineering Criteria.

Versions

In early stages of development PowerShell had code name 'Monad'. For some time later it was referred to as “Microsoft Shel” thus using different extension for script files - .msh

Currently Microsoft supports two versions of PowerShell - v1 and v2. Both versions use same extension - .ps1, and located in same path - %windir%\system32\WindowsPowerShell\v1.0\
Version 2.0 is latest and available for following operating systems: Windows XP SP2+, Windows 2003, Windows Vista, Windows 2008, Windows 7, Windows 2008 R2.

Features

Windows PowerShell include many functional features that distinguish it from other scripting languages and command shells. Some of this features available only in PowerShell 2.0 and some depends on specific Windows components. Here is the list of some such features:

  • [[PowerShell Object Pipeline | Object based pipeline]] that allows to pass objects from one cmdlet to another without need to use text parsing and formatting.
  • Easy access to [[.NET Framework]], [[WMI]], [[ADSI]], and use [[COM]] objects.
  • All objects in PowerShell presented in unified way, for example you can explore properties and methods of any object by piping it to Get-Member cmdlet.
  • [[PowerShell Providers]] for accessing registry, certificates, environment variables, functions, aliases, etc as virtual drives.
  • Modules and Snap-ins allows extension of the shell by adding new providers and cmdlets to it.
  • [[PowerShell Execution policy|Execution policies]] to control execution of signed/unsigned scripts or scripts received from not trusted sources.
  • In PowerShell, by pressing Tab key you can [[PowerShell autocompletion|autocomplete]] command names and parameters, elements of any provider (file system, registry, etc.), properties and methods of objects, and many more.
  • Rich integrated help. You can start exploring it by executing Get-Help cmdlet.
  • Integrated Script Environment ([[ISE]]) is built-in graphical script editor/shell. Its features include syntax highlighting, autocompletion and extensibility.
  • [[PowerShell Remoting]] feature that uses WinRM protocol create interactive remote shells and execute commands on one or multiple remote servers at once.
  • Multiple task can execute simultaneously in [[PowerShell Background Jobs|background jobs]]. This jobs can be started even on remote computers.

How to get PowerShell

Depending on operating system that you use, PowerShell may be installed by default, or require download or enabling of feature. Version 2 is available for download in package named [[Windows Management Framework]], this package also includes WinRM 2.0 and [[BITS]] 4.0 and can be downloaded here or by using [[Windows Update]] or [[WSUS]] if optional updates is selected.

The following table lists versions of PowerShell installed by default in different operating systems.

Operating System Installed version of PowerShell Comments
Windows XP SP2 None .Net Framework 2.0 SP1 is required before PowerShell installation
Windows Server 2003 None .Net Framework 2.0 SP1 is required before PowerShell installation
Windows Vista None   
Windows Server 2008 Full Installation None PowerShell v1.0 is included in distribution and can be installed as an optional feature. 
Windows Server 2008 Server Core None  There is no supported method to install PowerShell in Windows 2008 Server Core mode, because it doesn't supports any .NET Framework installation 
Windows 7 PowerShell v2   
Windows Server 2008 R2 Full Installation PowerShell v2  PowerShell ISE not installed by default, but can be enabled from features menu. 
Windows Server 2008 R2 Server Core None Can be installed as optional component using DISM command: dism.exe /online /enable-feature /featurename:"NetFx2-ServerCore" /featurename:"MicrosoftWindowsPowerShell"
Windows 8
PowerShell v3

Windows Server 8
PowerShell v3

PowerShell Snapins, Modules and other Extensions

Since its release PowerShell got quite a big adoption in a Microsoft products and in products of other vendors. There is also many extensions for PowerShell that written by the community.

  • [[PowerShell-enabled technologies]]
  • [[Popular PowerShell Modules]]
  • [[List of Windows Features and Roles that Take Advantage of Windows PowerShell]]

PowerShell hosts and editors

It is possible to create different custom hosting engines for PowerShell. Two [[PowerShell Hosts|such engines]] are provided with PowerShell: console host (powershell.exe) and scripting environment (PowerShell ISE). There is also some other shells built by different companies or community activists. Documentation for creating your own host can be found here.

Learning PowerShell

There are a vast amounts of information for learning Windows PowerShell. You can start from this hubs:

See Also

Other Languages

This article is also available in the following languages: