Windows PowerShell

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:
  • 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.
  • Execution policies to control execution of signed/unsigned scripts or scripts received from not trusted sources.
  • In PowerShell, by pressing Tab key you can 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 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 hosts and editors

It is possible to create different custom hosting engines for PowerShell. Two 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:

Other Languages

This article is also available in the following languages:

Leave a Comment
  • Please add 2 and 2 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Carsten Siemens edited Revision 32. Comment: Fixed typos

  • XAML guy edited Revision 30. Comment: removed en-US tag

  • Richard Mueller edited Revision 28. Comment: Added tag

  • MichalGajda edited Revision 27. Comment: added 'Other Languages' section and translation into pl-PL

  • Craig Lussier edited Revision 25. Comment: added en-US to tags and title

  • Ed Price - MSFT edited Revision 21. Comment: White space, a typo, and grammar

  • Vasily Gusev edited Revision 18. Comment: Renaming back

  • Vasily Gusev edited Revision 17. Comment: Renaming to create an alias

  • Vasily Gusev edited Revision 15. Comment: Small reorganization and modified features a bit

  • Vasily Gusev edited Revision 13. Comment: Added links to survival guide and to shells/editors page

Page 1 of 2 (15 items) 12
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Pronichkin edited Original. Comment: Fixed the table

  • Pronichkin edited Revision 1. Comment: Fixed the table (no, really)

  • Vasily Gusev edited Revision 2. Comment: Added products and features tables

  • Vasily Gusev edited Revision 3. Comment: Added Hosts and script editors

  • Vasily Gusev edited Revision 4. Comment: Screenshots corrections

  • Vasily Gusev edited Revision 6. Comment: Added standalone projects

  • Vasily Gusev edited Revision 7. Comment: Moved products and features to different article

  • Pronichkin edited Revision 12. Comment: resized the ISE pic

  • This would probably be better served if it were rolled into the current article social.technet.microsoft.com/.../windows-powershell-survival-guide.aspx

  • Arposh, yep, I know about survival guide, but I'm think that it is more like link collection than wiki page. Wiki allows you to easly structure material, reference it from many pages and so on. IMHO better to create separate articles: one for introduction to technology, one for products that use it, one for modules, an so on. Such separate articles are easier to update and they can be easily referenced both from product page or from link collections.

  • Vasily Gusev edited Revision 13. Comment: Added links to survival guide and to shells/editors page

  • Vasily Gusev edited Revision 14. Comment: Added link to List of Windows Features and Roles that Take Advantage of Windows PowerShell

  • Vasily Gusev edited Revision 15. Comment: Small reorganization and modified features a bit

  • Vasily Gusev edited Revision 17. Comment: Renaming to create an alias

  • Vasily Gusev edited Revision 18. Comment: Renaming back

Page 1 of 2 (24 items) 12