PowerShell: Difference between revisions
Joey-das-WBF (talk | contribs) |
KMaster888 (talk | contribs) update linking |
||
Line 1: | Line 1: | ||
{{Short description|Cross-platform command-line interface and scripting language for system and network administration}} |
|||
{{fixbunching|beg}} |
|||
{{Use American English|date=April 2023}} |
|||
{{Infobox Software |
|||
{{Use mdy dates|date=April 2023}} |
|||
| name = Windows PowerShell |
|||
| logo = [[File:Windows PowerShell icon.png|64px]] |
|||
| screenshot = [[File:Windows PowerShell 1.0 PD.png|225px]] |
|||
| caption = Screenshot of a sample PowerShell session |
|||
| developer = [[Microsoft|Microsoft Corporation]] |
|||
| released = November 14, 2006 |
|||
| latest_release_version = 2.0 |
|||
| latest_release_date = {{release date|2009|07|22}} |
|||
| operating_system = [[Windows XP]]<br />[[Windows Server 2003]]<br />[[Windows Vista]]<br />[[Windows Server 2008]]<br />[[Windows 7]]<br>[[Windows Server 2008 R2]] |
|||
| platform = [[x86]], [[x86-64]], [[Itanium]] |
|||
| language = [[Multilingualism|Multilingual]] |
|||
| status = Active |
|||
| genre = [[Shell (computing)|Operating system shell]] |
|||
| source_model = [[Closed source]] |
|||
| license = MS-[[EULA]] |
|||
| website = [http://www.microsoft.com/powershell Windows PowerShell] |
|||
}} |
|||
{{fixbunching|mid}} |
|||
{{Infobox programming language |
{{Infobox programming language |
||
| name |
| name = PowerShell |
||
| logo |
| logo = PowerShell Core 6.0 icon.png |
||
| screenshot = File:PowerShell 7.4.0 Core on Windows 11, 23H2.png |
|||
| paradigm = [[multi-paradigm programming language|Multi-paradigm]]: [[Imperative programming|imperative]], [[Pipeline programming|pipeline]], [[Object-oriented programming|object-oriented]], [[Functional programming|functional]], [[Reflective programming|reflective]] |
|||
| screenshot caption = Screenshot of a PowerShell 7 session in [[Windows Terminal]] |
|||
| year = 2006 |
|||
| paradigm = [[Imperative programming|Imperative]], [[Pipeline (software)|pipeline]], [[Object-oriented programming|object-oriented]], [[Functional programming|functional]] and [[Reflective programming|reflective]] |
|||
| designer = [[Jeffrey Snover]], [[Bruce Payette]], [[James Truher]] (et al.) |
|||
| released = {{start date and age|2006|11|14}} |
|||
| developer = [[Microsoft|Microsoft Corporation]] |
|||
| designer = [[Jeffrey Snover]], Bruce Payette, James Truher (et al.) |
|||
| typing = [[Strongly-typed programming language|strong]], [[Type safety|safe]], [[Type inference|implicit]], [[dynamic typing|dynamic]] |
|||
| developer = [[Microsoft]] |
|||
| dialects = |
|||
| latest release version = 7.4.6 |
|||
| influenced_by = [[C Sharp (programming language)|C#]], [[DIGITAL Command Language|DCL]], [[Korn shell|ksh]], [[Perl]], [[Ruby (programming language)|Ruby]]/[[Lisp (programming language)|LISP]], [[AS/400 Control Language|CL]], [[SQL]], [[COMMAND.COM]]/ [[cmd.exe]],{{citation needed|date=October 2010}} [[Tcl]]<ref> |
|||
| latest release date = {{sda|2024|10|22}}<ref>{{Cite web |
|||
{{cite web |
|||
| url = https://apps.microsoft.com/detail/9mz1snwt0n5d |
|||
| last = Snover |
|||
| |
| title = PowerShell |
||
| |
| website = Microsoft Apps |
||
| access-date = 2024-10-24}}</ref><ref>{{Cite web |title=Release v7.4.6 Release of PowerShell |url=https://github.com/PowerShell/PowerShell/releases/tag/v7.4.6 |access-date=2024-10-22 | website = PowerShell/PowerShell repo | publisher = [[Microsoft]] | via = [[GitHub.com]] |language=en}}</ref> |
|||
| date = 2008-05-25 |
|||
| typing = [[Strongly-typed programming language|Strong]], [[Type safety|safe]], [[Type inference|implicit]] and [[dynamic typing|dynamic]] |
|||
| url = http://blogs.msdn.com/b/powershell/archive/2008/05/25/powershell-and-wpf-wtf.aspx |
|||
| dialects = |
|||
| accessdate = 2010-10-24 |
|||
| influenced = |
|||
}}</ref> |
|||
| programming language = [[C Sharp (programming language)|C#]] |
|||
| influenced = |
|||
| operating system = {{Plainlist| |
|||
| platform = [[.NET Framework]] |
|||
* [[Windows 7]] and later |
|||
* [[Windows Server 2008 R2]] and later |
|||
* [[macOS 10.12]] and later |
|||
* [[Ubuntu (operating system)|Ubuntu]] 14.04, 16.04, 18.04, 20.04 and 22.04 |
|||
* [[Debian]] 8.7+, 9, 10 and 11 |
|||
* [[CentOS]] 7 and 8 |
|||
* [[Red Hat Enterprise Linux]] 7 and 8 |
|||
* [[openSUSE]] 42.2, 42.3, 15.0, 15.1, 15.2 |
|||
* [[Fedora (operating system)|Fedora]] 28, 29, 30 |
|||
}} |
|||
| platform = PowerShell: [[.NET]]<br />Windows PowerShell: [[.NET Framework]] |
|||
| license = [[MIT License]]<ref>{{cite web|url=https://github.com/PowerShell/PowerShell|title=PowerShell for every system!|date=June 12, 2017|via=[[GitHub.com]]}}</ref> (but the Windows component remains [[proprietary software|proprietary]]) |
|||
| influenced_by = [[Python (programming language)|Python]], [[KornShell|Ksh]], [[Perl]], [[C Sharp (programming language)|C#]], [[Control Language|CL]], [[DIGITAL Command Language|DCL]], [[SQL]], [[Tcl]], [[Tk (software)|Tk]],<ref name="snover2008">{{cite web |
|||
| last = Snover |
|||
| first = Jeffrey |
|||
| title = PowerShell and WPF: WTF |
|||
| date = May 25, 2008 |
|||
| url = https://blogs.msdn.microsoft.com/powershell/2008/05/25/powershell-and-wpf-wtf/ |
|||
| website = Windows PowerShell Blog |
|||
| publisher = Microsoft |
|||
}}</ref> [[Chef (software)|Chef]], [[Puppet (software)|Puppet]] |
|||
| file extensions = {{Plainlist| |
|||
*.ps1 (Script) |
|||
*.ps1xml (XML Document) |
|||
*.psc1 (Console File) |
|||
*.psd1 (Data File) |
|||
*.psm1 (Script Module) |
|||
*.pssc (Session Configuration File) |
|||
*.psrc (Role Capability File) |
|||
*.cdxml (Cmdlet Definition XML Document) |
|||
}} |
|||
}} |
}} |
||
{{fixbunching|end}} |
|||
''' |
'''PowerShell''' is a task automation and [[configuration management]] program from [[Microsoft]], consisting of a [[command-line shell]] and the associated [[scripting language]]. Initially a Windows component only, known as '''Windows PowerShell''', it was made [[open-source software|open-source]] and [[cross-platform]] on August 18, 2016, with the introduction of '''PowerShell Core'''.<ref name=ars-opensource /> The former is built on the [[.NET Framework]], the latter on [[.NET]] (previously .NET Core). |
||
PowerShell is bundled with all currently supported [[List of Microsoft Windows versions|Windows versions]], and can also be installed on [[macOS]] and [[Linux]].<ref name="ars-opensource" /> Since [[Windows 10]] build 14971, PowerShell replaced [[cmd.exe|Command Prompt (cmd.exe)]] and became the default [[command shell]] for [[File Explorer]].<ref>{{cite web|url=https://blogs.windows.com/windows-insider/2016/11/17/announcing-windows-10-insider-preview-build-14971-for-pc/|title=Announcing Windows 10 Insider Preview Build 14971 for PC|date=November 17, 2016 }}</ref><ref>{{cite web|url=https://support.microsoft.com/en-us/windows/powershell-is-replacing-command-prompt-fdb690cf-876c-d866-2124-21b6fb29a45f|title=PowerShell is replacing Command Prompt}}</ref> |
|||
In PowerShell, administrative tasks are generally performed by ''cmdlets'' (pronounced ''command-lets''), specialized .NET [[Class (computer science)|classes]] implementing a particular operation. Sets of cmdlets may be combined together in ''scripts'', ''executables'' (which are standalone applications), or by instantiating regular .NET classes (or WMI/COM Objects).<ref name="how">{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714658.aspx | title = How Windows PowerShell works | publisher = [[MSDN]] | accessdate = 2007-11-27}}</ref><ref name="MSDN">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/12/PowerShell/default.aspx | title = Extend Windows PowerShell With Custom Commands| publisher = [[MSDN]] | accessdate = 2007-11-27}}</ref> These work by accessing data in different data stores, like the [[filesystem]] or [[Windows Registry|registry]], which are made available to the PowerShell runtime via Windows PowerShell ''providers''. |
|||
In PowerShell, administrative tasks are generally performed via ''cmdlets'' (pronounced ''command-lets''), which are specialized .NET [[class (computer programming)|classes]] implementing a particular operation. These work by accessing data in different data stores, like the [[file system]] or [[Windows Registry]], which are made available to PowerShell via ''providers''. Third-party developers can add cmdlets and providers to PowerShell.<ref name="how" /><ref name="MSDN">{{cite magazine | last=Truher |first=Jim | date=December 2007 | url = https://msdn.microsoft.com/en-us/magazine/cc163293.aspx | title = Extend Windows PowerShell With Custom Commands| magazine = [[MSDN Magazine]] | publisher=Microsoft | archive-url=https://web.archive.org/web/20081006195551/http://msdn.microsoft.com/en-us/magazine/cc163293.aspx |archive-date=October 6, 2008}}</ref> Cmdlets may be used by scripts, which may in turn be packaged into modules. Cmdlets work in tandem with the .NET [[application programming interface|API]]. |
|||
Windows PowerShell also provides a hosting [[API|mechanism]] with which the Windows PowerShell runtime can be embedded inside other applications. These applications then leverage Windows PowerShell functionality to implement certain operations, including those exposed via the [[graphical user interface|graphical interface]]. This capability has been utilized by [[Microsoft Exchange Server]] 2007<ref name="how"/><ref>{{cite web | url = http://articles.techrepublic.com.com/5100-10878_11-6147304.html | title = Exchange 2007: Get used to the command line | publisher = Tech Republic | accessdate = 2007-11-28}}</ref> to expose its management functionality as PowerShell cmdlets and providers and implement the [[Graphical User Interface|graphical]] management tools as PowerShell hosts which invoke the necessary cmdlets. Other [[Microsoft]] applications including [[Microsoft SQL Server 2008]]<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2007/11/13/sql-server-support-for-powershell.aspx | title = SQL Server Support for PowerShell! | accessdate = 2007-11-28}}</ref> also expose their management interface via PowerShell cmdlets. With PowerShell, graphical interface-based management applications on Windows are layered on top of Windows PowerShell. In the future all Microsoft applications running on the Windows platform are to be PowerShell aware.{{Citation needed|date=October 2010}} |
|||
PowerShell's support for [[.NET Remoting]], [[WS-Management]], [[Common Information Model (computing)|CIM]], and [[SSH]] enables administrators to perform administrative tasks on both local and remote Windows systems. PowerShell also provides a hosting [[API]] with which the PowerShell runtime can be embedded inside other applications. These applications can then use PowerShell functionality to implement certain operations, including those exposed via the [[graphical user interface|graphical interface]]. This capability has been used by [[Microsoft Exchange Server]] 2007 to expose its management functionality as PowerShell cmdlets and providers and implement the [[Graphical user interface|graphical]] management tools as PowerShell hosts which invoke the necessary cmdlets.<ref name="how" /><ref name="lowe2007">{{cite web|title=Exchange 2007: Get used to the command line|url=http://www.techrepublic.com/article/exchange-2007-get-used-to-the-command-line/|last=Lowe|first=Scott|date=January 4, 2007|work=[[TechRepublic]]|publisher=[[CBS Interactive]]|url-status=live|archive-url=https://web.archive.org/web/20181116084157/https://www.techrepublic.com/article/exchange-2007-get-used-to-the-command-line/|archive-date=November 16, 2018|access-date=May 12, 2020}}</ref> Other Microsoft applications including [[Microsoft SQL Server 2008]] also expose their management interface via PowerShell cmdlets.<ref name="snover2007b">{{cite web|title=SQL Server Support for PowerShell!|url=http://blogs.msdn.com/powershell/archive/2007/11/13/sql-server-support-for-powershell.aspx|author=Snover|first=Jeffrey|date=November 13, 2007|website=Windows PowerShell Blog|publisher=Microsoft|type=blog posting|archive-url=https://web.archive.org/web/20071115215316/http://blogs.msdn.com/powershell/archive/2007/11/13/sql-server-support-for-powershell.aspx|archive-date=November 15, 2007|access-date=November 13, 2007}}</ref> |
|||
Windows PowerShell includes its own extensive, console-based help, similar to [[Manual page (Unix)|man pages]] in [[Unix shell]]s via the <code>Get-Help</code> cmdlet. |
|||
PowerShell includes its own extensive, [[command-line interface|console-based]] help (similar to [[man page]]s in [[Unix shell]]s) accessible via the <code>Get-Help</code> cmdlet. Updated local help contents can be retrieved from the Internet via the <code>Update-Help</code> cmdlet. Alternatively, help from the web can be acquired on a case-by-case basis via the <code class="nowrap">-online</code> switch to <code>Get-Help</code>. |
|||
== Versions == |
|||
Initially using the code name "Monad", PowerShell was first shown publicly at the Professional Developers Conference in September 2003. There are currently two versions of PowerShell supported by Microsoft.<ref>{{cite web |
|||
| url = http://blogs.msdn.com/b/powershell/archive/2008/12/30/download-windows-powershell.aspx |
|||
| title = Download Windows PowerShell |
|||
| date = 2008-12-30 |
|||
| accessdate = 2010-06-27 |
|||
}}</ref> |
|||
== Background == |
|||
Version 1.0 was released in 2006 for [[Windows XP]] SP2/SP3, [[Windows Server 2003]], and [[Windows Vista]]. For [[Windows Server 2008]], it is included as an optional feature. |
|||
The [[command-line interpreter]] (CLI) has been an inseparable part of most Microsoft [[operating system]]s. [[MS-DOS]] and [[Xenix]] relied almost exclusively on the CLI (though {{nowrap|MS-DOS 5}} also came with a complementary graphical [[DOS Shell]].) The Windows 9x family came bundled with [[COMMAND.COM]], the command-line environment of MS-DOS. The [[Windows NT]] and [[Windows Embedded Compact|Windows CE]] families, however, came with a new [[cmd.exe]] that bore strong similarities to COMMAND.COM. Both environments support a few basic internal commands and a primitive scripting language ([[batch file]]s), which can be used to automate various tasks. However, they cannot automate all facets of Windows [[graphical user interface]] (GUI) because command-line equivalents of operations are limited and the scripting language is elementary. |
|||
Microsoft attempted to address some of these shortcomings by introducing the [[Windows Script Host]] in 1998 with [[Windows 98]], and its command-line based host, <code>cscript.exe</code>. It integrates with the [[Active Scripting|Active Script]] engine and allows scripts to be written in compatible languages, such as [[JScript]] and [[VBScript]], leveraging the [[application programming interface|APIs]] exposed by applications via the component object model ([[Component Object Model|COM]]). Its shortcomings are: its documentation is not very accessible, and it quickly gained a reputation as a system [[Vulnerability (computing)|vulnerability vector]] after several high-profile [[computer virus]]es exploited weaknesses in its security provisions. Different versions of Windows provided various special-purpose command-line interpreters (such as [[netsh]] and [[Windows Management Instrumentation Command-line|WMIC]]) with their own command sets but they were not interoperable. [[Windows Server 2003]] further attempted to improve the command-line experience but scripting support was still unsatisfactory.<ref name="pcmag-server2003">{{cite web |last=Dragan |first=Richard V. |date=April 23, 2003 |title=Windows Server 2003 Delivers Improvements All Around |url=https://www.pcmag.com/archive/windows-server-2003-delivers-improvements-all-around-40764 |magazine=[[PCMag.com]] |publisher=[[Ziff Davis]] |quote=A standout feature here is that virtually all admin utilities now work from the command line (and most are available through telnet).}}</ref> |
|||
Version 2.0 is integrated with [[Windows 7]] and [[Windows Server 2008 R2]] and is released for [[Windows XP]] with Service Pack 3, [[Windows Server 2003]] with Service Pack 2, [[Windows Vista]] with Service Pack 1, and [[Windows Server 2008]].<ref>{{cite web |
|||
| url = http://blogs.msdn.com/powershell/archive/2009/10/27/windows-management-framework-is-here.aspx |
|||
| title = Windows Management Framework is here! |
|||
| date = 2009-10-27 |
|||
| accessdate = 2009-10-30 |
|||
}}</ref> |
|||
== |
=== Kermit === |
||
By the late 1990s, [[Intel]] had come to Microsoft asking for help in making Windows, which ran on Intel CPUs, a more appropriate platform to support the development of future Intel CPUs. At the time, Intel CPU development was accomplished on [[Sun Microsystems]] computers which ran [[Oracle Solaris|Solaris]] (a [[Unix]] variant) on [[RISC]]-architecture CPUs. The ability to run Intel's many [[KornShell]] automation scripts on Windows was identified as a key capability. Internally, Microsoft began an effort to create a Windows port of Korn Shell, which was code-named Kermit.<ref>{{cite book |last1=Jones |first1=Don |title=Shell of an Idea: The Untold History of PowerShell |date=2020 |isbn=978-1-9536450-3-6 |page=25|publisher=Don Gannon-Jones }}</ref> Intel ultimately pivoted to a [[Linux]]-based development platform that could run on Intel CPUs, rendering the Kermit project redundant. However, with a fully funded team, Microsoft program manager [[Jeffrey Snover]] realized there was an opportunity to create a more general-purpose solution to Microsoft's problem of administrative automation. |
|||
Every released version of [[Microsoft DOS]] and [[Microsoft Windows]] for [[personal computer]]s has included a command-line interface tool ([[shell (computing)|shell]]). These are <code>[[COMMAND.COM]]</code> (in installations relying on [[MS-DOS]], including [[Windows 9x]]) and <code>[[Command Prompt (Windows)|cmd.exe]]</code> (in [[Windows NT]]-family operating systems). These are regular [[command line interpreter]]s that support a few basic commands. For other purposes, a separate [[console application]] needs to be provided, to be invoked from these shells. They also include a scripting language ([[batch files]]), which can be used to automate various tasks. However, they cannot be used to automate all facets of [[graphical user interface|GUI]] functionality, in part because command-line equivalents of operations exposed via the graphical interface are limited, and the scripting language is elementary and does not allow the creation of complex scripts. In [[Windows Server 2003]], the situation was improved,<ref name="pcmag-server2003">{{cite web |
|||
|url = http://www.pcmag.com/article2/0,2704,1040410,00.asp |
|||
|title = Windows Server 2003 Delivers Improvements All Around |
|||
|accessdate = 2007-11-02 |
|||
|last=Dragan|first = Richard V. |
|||
|date = April 23, 2003 |
|||
|publisher = [[PC Magazine]] |
|||
|quote = A standout feature here is that virtually all admin utilities now work from the command line (and most are available through telnet). |
|||
}}</ref> but scripting support was still considered unsatisfactory. |
|||
=== Monad === |
|||
Microsoft attempted to address some of these shortcomings by introducing the [[Windows Script Host]] in 1998 with [[Windows 98]], and its command-line based host: <code>cscript.exe</code>. It integrates with the [[Active Script|Active Script engine]] and allows scripts to be written in compatible languages, such as [[JScript]] and [[VBScript]], leveraging the [[API]]s exposed by applications via [[Component Object Model|COM]]. However, it too has its own deficiencies: it is not integrated with the shell, its documentation is not very accessible, and it quickly gained a reputation as a system [[Vulnerability (computer science)|vulnerability vector]] after several high-profile [[computer viruses]] exploited weaknesses in its security provisions. Different versions of Windows provided various special-purpose command line interpreters (such as [[netsh]] and [[Windows Management Instrumentation Command-line|WMIC]]) with their own command sets. None of them were integrated with the command shell; nor were they interoperable. |
|||
By 2002, Microsoft had started to develop a new approach to command-line management, including a CLI called Monad (also known as {{nowrap|Microsoft Shell}} or MSH). The ideas behind it were published in August 2002 in a white paper called the "Monad Manifesto" by its chief architect, [[Jeffrey Snover]].<ref name="MonadManifesto">{{cite news |author1=Jeffrey P. Snover |title=Monad Manifesto |url=https://www.jsnover.com/Docs/MonadManifesto.pdf |access-date=April 2, 2021 |work=Windows PowerShell Blog |publisher=Microsoft |date=August 8, 2002}}</ref> In a 2017 interview, Snover explains the genesis of PowerShell, saying that he had been trying to make [[Unix]] tools available on Windows, which didn't work due to "[[Unix philosophy|core architectural difference[s] between Windows and Linux]]". Specifically, he noted that [[Linux]] considers everything a [[text file]], whereas Windows considers everything an "[[application programming interface|API]] that returns structured data". They were fundamentally incompatible, which led him to take a different approach.<ref>{{cite podcast|url=https://www.heavybit.com/library/podcasts/to-be-continuous/ep-37-the-man-behind-windows-powershell/|title=The Man Behind Windows PowerShell|publisher=Heavybit|website=To Be Continuous|host=Biggar and Harbaugh|date=September 14, 2017|access-date=September 14, 2017}}</ref> |
|||
Monad was to be a new extensible CLI with a fresh design capable of automating a range of core administrative tasks. Microsoft first demonstrated Monad publicly at the Professional Development Conference in Los Angeles in October 2003. A few months later, they opened up private beta, which eventually led to a public beta. Microsoft published the first Monad public [[Development stage#Beta|beta release]] on June 17, 2005, and the Beta 2 on September 11, 2005, and Beta 3 on January 10, 2006. |
|||
|url=http://blogs.msdn.com/powershell/archive/2006/04/25/583344.aspx |
|||
=== PowerShell === |
|||
[[File:Windows PowerShell 1.0 PD.png|thumb|The first version of PowerShell]] |
|||
|date=April 25, 2006 |
|||
On April 25, 2006, not long after the initial Monad announcement, Microsoft announced that Monad had been renamed '''Windows PowerShell''', positioning it as a significant part of its management technology offerings.<ref name="monad-renamed">{{cite web |
|||
|accessdate=2006-04-26 |
|||
|url=https://blogs.msdn.microsoft.com/powershell/2006/04/25/windows-powershell-monad-has-arrived/ |
|||
|last=Snover |
|||
|title=Windows PowerShell (Monad) Has Arrived |
|||
|first=Jeffrey |
|||
|date=April 25, 2006 |
|||
|work=Windows PowerShell team blog |
|||
|website=Windows PowerShell Blog |
|||
|publisher=MSDN |
|||
|publisher=[[Microsoft]] |
|||
}}</ref> Release Candidate 1 of PowerShell was released at the same time. |
|||
Release Candidate |
}}</ref> Release Candidate (RC) 1 of PowerShell was released at the same time. A significant aspect of both the name change and the RC was that this was now a component of Windows, rather than a mere add-on. |
||
|url=http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx |
|||
Release Candidate 2 of PowerShell version 1 was released on September 26, 2006, with final [[Software release life cycle#Release to the Web (RTW)|release to the web]] on November 14, 2006. PowerShell for earlier versions of Windows was released on January 30, 2007.<ref name="powershell-vista">{{cite web |
|||
|title=Windows PowerShell : Windows PowerShell & Windows Vista |
|||
|url=http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx |
|||
|date=November 15, 2006 |
|||
|type=blog posting |
|||
|accessdate=2007-01-26 |
|||
|title=Windows PowerShell & Windows Vista |
|||
|date=November 15, 2006 |
|||
|last=Snover |
|last=Snover |
||
|first=Jeffrey |
|first=Jeffrey |
||
| |
|website=Windows PowerShell Blog |
||
|publisher= |
|publisher=[[Microsoft]] |
||
}}</ref> |
}}</ref> PowerShell v2.0 development began before PowerShell v1.0 shipped. During the development, Microsoft shipped three [[Community Technology Preview|community technology previews (CTP)]]. Microsoft made these releases available to the public. The last CTP release of Windows PowerShell v2.0 was made available in December 2008. |
||
PowerShell v2.0 was completed and released to manufacturing in August 2009, as an integral part of Windows 7 and Windows Server 2008 R2. Versions of PowerShell for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008 were released in October 2009 and are available for download for both 32-bit and 64-bit platforms.<ref name=" |
PowerShell v2.0 was completed and released to manufacturing in August 2009, as an integral part of Windows 7 and Windows Server 2008 R2. Versions of PowerShell for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008 were released in October 2009 and are available for download for both 32-bit and 64-bit platforms.<ref name="PowerShell-V2-RTM">{{cite web |
||
|url=http://support.microsoft.com/kb/968929 |
|url=http://support.microsoft.com/kb/968929 |
||
|title=Windows PowerShell |
|title=Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) |
||
|website=Support |
|||
}}</ref> |
|||
|publisher=[[Microsoft]] |
|||
|date=September 30, 2013 |
|||
|url-status=dead<!--citation points at old version of page, tantamount to dead--> |
|||
|archive-date=October 13, 2013 |
|||
|archive-url=https://web.archive.org/web/20131013100052/http://support.microsoft.com/kb/968929 |
|||
}}</ref> In an October 2009 issue of ''[[Microsoft TechNet|TechNet Magazine]]'', Microsoft called proficiency with PowerShell "the single most important skill a Windows [[System administrator|administrator]] will need in the coming years".<ref name="posey">{{cite news |last1=Posey |first1=Brien |title=10 reasons why you should learn to use PowerShell |url=https://www.techrepublic.com/blog/10-things/10-reasons-why-you-should-learn-to-use-powershell/ |access-date=April 2, 2021 |work=TechRepublic |date=October 6, 2009}}</ref> |
|||
Windows 10 shipped with Pester, a script validation suite for PowerShell.<ref>{{cite web|url=https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/14/what-is-pester-and-why-should-i-care/|title=What is Pester and Why Should I Care?|date=December 14, 2015}}</ref> |
|||
==Overview== |
|||
There are four kinds of commands Windows PowerShell can execute: |
|||
* 'cmdlets', which are [[.NET Framework|.NET]] programs, written by a developer, compiled into a [[dynamic-link library]] and loaded by a PowerShell script, |
|||
* PowerShell scripts (files suffixed by '.ps1'), |
|||
* PowerShell functions, |
|||
* [[executable]] programs. |
|||
If a command is an executable program, PowerShell launches it in a separate [[Process (computing)|process]]; if it is a cmdlet, it is executed in the PowerShell process. PowerShell also provides an interactive [[command line interface]], wherein the commands can be entered and their output displayed. The user interface, based on the [[Win32 console]], offers customizable [[Command line completion|tab completion]] but lacks [[syntax highlighting]]. PowerShell also enables the creation of ''[[alias (command)|aliases]]'' for cmdlets, which are textually translated by PowerShell into invocations of the original commands. PowerShell also supports both [[named parameter|named]] and positional [[Parameter (computer science)|parameters]] for commands. In executing a cmdlet, the job of binding the argument value to the parameter is done by PowerShell itself, but, for external executables, arguments are passed via the [[argv]] (or equivalent) variable array to be parsed by the executable. |
|||
[[File:Powershell for Linux on Ubuntu 22.10.png|thumb|PowerShell for Linux 7.3.1 on [[Ubuntu (operating system)|Ubuntu]] 22.10]] |
|||
Another concept used by PowerShell is that of a ''pipeline''. Like [[Pipeline (Unix)|Unix pipelines]], PowerShell pipelines are used to compose complex commands, allowing the output of one command to be passed as input to another. A pipeline is set up by ''piping'' the output of one command (or pipeline) to another command, using the <code>|</code> operator. But, unlike its Unix counterpart, the PowerShell pipeline is an [[Pipeline (software)|object pipeline]]; that is, the data passed between cmdlets are fully [[type system|typed]] [[Object (computer science)|objects]], rather than character streams. When data is piped as objects, the elements they encapsulate retain their structure and types across cmdlets, without the need for any [[serialization (computing)|serialization]] or explicit [[parser|parsing]] of the stream, as would be the need if only character streams were shared. An object can also encapsulate certain functions that work on the contained data. These also become available to the recipient command for use.<ref>{{cite web | url = http://www.microsoft.com/technet/technetmag/issues/2007/07/PowerShell/default.aspx | title = Rethinking the Pipeline | accessdate = 2007-11-28}}</ref><ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/aa347685.aspx | title = Windows PowerShell Object Concepts | accessdate = 2007-11-28}}</ref> For the last cmdlet in a pipeline, PowerShell automatically pipes its output object to the <code>Out-Default</code> cmdlet, which transforms the objects into a stream of format objects and then renders those to the screen.<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2006/04/30/586973.aspx | title = How PowerShell Formatting and Outputting REALLY works| accessdate = 2007-11-28}}</ref><ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2006/06/21/641738.aspx | title = More - How does PowerShell formatting really work?| accessdate = 2007-11-28}}</ref> |
|||
On August 18, 2016, Microsoft announced<ref>{{Cite web|url=https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/ |title=PowerShell is open sourced and is available on Linux |website=Microsoft Azure Blog |publisher=[[Microsoft]]|date=August 18, 2016 |first=Jeffrey |last=Snover}}</ref> that they had made PowerShell open-source and cross-platform with support for Windows, [[macOS]], [[CentOS]] and [[Ubuntu (operating system)|Ubuntu]].<ref name="ars-opensource">{{cite web|title=PowerShell is Microsoft's latest open source release, coming to Linux, OS X|url=https://arstechnica.com/information-technology/2016/08/powershell-is-microsofts-latest-open-source-release-coming-to-linux-os-x/|last1=Bright|first1=Peter|date=August 18, 2016|website=[[Ars Technica]]|publisher=[[Condé Nast]]|url-status=live|archive-url=https://web.archive.org/web/20200409020253/https://arstechnica.com/information-technology/2016/08/powershell-is-microsofts-latest-open-source-release-coming-to-linux-os-x/|archive-date=April 9, 2020|access-date=May 12, 2020}}</ref> The source code was published on [[GitHub]].<ref>{{Cite web|url=https://github.com/PowerShell/PowerShell|title=PowerShell/PowerShell|website=GitHub|access-date=August 18, 2016}}</ref> The move to open source created a second incarnation of PowerShell called "PowerShell Core", which runs on [[.NET Core]]. It is distinct from "Windows PowerShell", which runs on the full [[.NET Framework]].<ref>{{cite web|last1=Hansen|first1=Kenneth|last2=Calvo|first2=Angel|title=PowerShell on Linux and Open Source!|url=https://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/|website=Windows PowerShell Blog|publisher=[[Microsoft]]|date=August 18, 2016}}</ref> Starting with version 5.1, PowerShell Core is bundled with [[Windows Server 2016#Nano Server|Windows Server 2016 Nano Server]].<ref>{{cite web |url=https://www.zdnet.com/article/microsoft-open-sources-powershell-brings-it-to-linux-and-mac-os-x/ |title=Microsoft open sources PowerShell; brings it to Linux and Mac OS X |work=[[ZDNet]] |publisher=[[CBS Interactive]] |first=Mary Jo |last=Foley |author-link=Mary Jo Foley |date=August 18, 2016}}</ref><ref name=":0">{{Cite web|url=https://technet.microsoft.com/en-us/windows-server-docs/get-started/powershell-on-nano-server|title=PowerShell on Nano Server|date=October 20, 2016|website=[[Microsoft TechNet|TechNet]]|publisher=[[Microsoft]]}}</ref> |
|||
== Design == |
|||
Because all PowerShell objects are .NET objects, they share a <code>.ToString()</code> method, which retrieves the text representation of the data in an object. Windows PowerShell uses this method to convert an object to text. In addition, it also allows formatting definitions to be specified, so the text representation of objects may be customized by choosing which data elements to display, and how. However, in order to maintain backwards compatibility, if an external executable is used in a pipeline, it receives a text stream representing the object, and does not integrate with the PowerShell type system. |
|||
A key design tactic for PowerShell was to leverage the large number of [[API]]s that already existed in Windows, Windows Management Instrumentation, .NET Framework, and other software. PowerShell cmdlets "wrap around" existing functionality. The intent with this tactic is to provide an administrator-friendly, more-consistent interface between administrators and a wide range of underlying functionality. With PowerShell, an administrator doesn't need to know .NET, WMI, or low-level API coding, and can instead focus on using the cmdlets exposed by PowerShell. In this regard, PowerShell creates little new functionality, instead focusing on making existing functionality more accessible to a particular audience.<ref>{{cite book |last1=Jones |first1=Don |title=Shell of an Idea: The Untold History of PowerShell |date=2020 |isbn=978-1-9536450-3-6 |page=45|publisher=Don Gannon-Jones }}</ref> |
|||
=== Grammar === |
|||
The PowerShell ''Extended Type System'' (''ETS'') is based on the .NET type system, but with extended semantics (e.g. propertySets and 3rd party extensibility) . For example, it enables the creation of different views of objects by exposing only a subset of the data fields, properties, and methods, as well as specifying custom formatting and sorting behavior. These views are mapped to the original object using [[XML]]-based configuration files.<ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714419.aspx | title = Windows PowerShell Extended Type System | accessdate = 2007-11-28}}</ref> |
|||
PowerShell's developers based the core grammar of the tool on that of the [[POSIX|POSIX 1003.2]] [[KornShell]].<ref> |
|||
{{cite book |
|||
| last1 = Payette |
|||
| first1 = Bruce |
|||
| title = Windows PowerShell in Action |
|||
| url = https://books.google.com/books?id=MYZQAAAAMAAJ |
|||
| series = Manning Pubs Co Series |
|||
| publisher = Manning |
|||
| date = 2008 |
|||
| page = 27 |
|||
| isbn = 9781932394900 |
|||
| access-date = July 22, 2016 |
|||
| quote = The core PowerShell language is based on the POSIX 1003.2 grammar for the [[KornShell|Korn shell]]. |
|||
}} |
|||
</ref> |
|||
However, PowerShell's language was also influenced by [[PHP]], [[Perl]], and many other existing languages.<ref>{{cite book |last1=Jones |first1=Don |title=Shell of an Idea: The Untold History of PowerShell |date=2020 |isbn=978-1-9536450-3-6 |page=109|publisher=Don Gannon-Jones }}</ref> |
|||
===Cmdlets=== |
|||
Cmdlets are specialized commands in the PowerShell environment that implement specific functions. These are the native commands in the PowerShell stack. Cmdlets follow a ''<verb>''-''<noun>'' naming pattern, such as ''Get-ChildItem'', helping to make them self-descriptive.<ref name="cmdlets">{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714395.aspx | title = Windows PowerShell Cmdlets | accessdate = 2007-11-28}}</ref> Cmdlets output their results as objects, or collections thereof (including arrays), and can optionally receive input in that form, making them suitable for use as recipients in a pipeline. But, whereas PowerShell allows arrays and other collections of objects to be written to the pipeline, cmdlets always process objects individually. For collections of objects, PowerShell invokes the cmdlet on each object in the collection, in sequence.<ref name="cmdlets"/> |
|||
=== Named Commands === |
|||
Cmdlets are specialized .NET [[class (computing)|classes]], which the PowerShell runtime instantiates and invokes when they are run. Cmdlets derive either from <code>Cmdlet</code> or from <code>PSCmdlet</code>, the latter being used when the cmdlet needs to interact with the PowerShell runtime.<ref name="cmdlets"/> These base classes specify certain methods - <code>BeginProcessing()<code>, <code>ProcessRecord()</code> and <code>EndProcessing()</code> - one of which the cmdlet's implementation overrides to provide the functionality. Whenever a cmdlet is run, these methods are invoked by PowerShell in sequence, with <code>ProcessRecord()</code> being called if it receives pipeline input.<ref name="firstcmdlet">{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714622.aspx |title = Creating Your First Cmdlet | accessdate = 2007-11-28}}</ref> If a collection of objects is piped, the method is invoked for each object in the collection. The class implementing the Cmdlet must have one .NET [[Attribute (computing)|attribute]] - <code>CmdletAttribute</code> - which specifies the verb and the noun that make up the name of the cmdlet. Common verbs are provided as an [[Enumerated type|enum]]. |
|||
Windows PowerShell can execute four kinds of named commands:<ref>{{cite web |title=about_Command_Precedence |url=https://technet.microsoft.com/en-us/library/hh848304.aspx |website=[[Microsoft TechNet|TechNet]] |publisher=[[Microsoft]] |date=May 8, 2014}}</ref> |
|||
* ''cmdlets'' ([[.NET Framework]] programs designed to interact with PowerShell) |
|||
If a cmdlet receives either pipeline input or command-line parameter input, there must be a corresponding [[Property (programming)|property]] in the class, with a [[Mutator method|mutator]] implementation. PowerShell invokes the mutator with the parameter value or pipeline input, which is saved by the mutator implementation in class variables. These values are then referred to by the methods which implement the functionality. Properties that map to command-line parameters are marked by <code>ParameterAttribute</code><ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714663.aspx | title = Adding parameters That Process Command Line Input | accessdate = 2007-11-28}}</ref> and are set before the call to <code>BeginProcessing()</code>. Those which map to pipeline input are also flanked by <code>ParameterAttribute</code>, but with the <code>ValueFromPipeline</code> attribute parameter set.<ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714597.aspx | title = Adding parameters That Process Pipeline Input | accessdate = 2007-11-28}}</ref> |
|||
* PowerShell scripts (files suffixed by <code>.ps1</code>) |
|||
* PowerShell functions |
|||
* Standalone [[executable]] programs |
|||
If a command is a standalone executable program, PowerShell launches it in a separate [[process (computing)|process]]; if it is a cmdlet, it executes in the PowerShell process. PowerShell provides an interactive [[command-line interface]], where the commands can be entered and their output displayed. The user interface offers customizable [[Command-line completion|tab completion]]. PowerShell enables the creation of ''[[alias (command)|aliases]]'' for cmdlets, which PowerShell textually translates into invocations of the original commands. PowerShell supports both [[named parameter|named]] and positional [[parameter (computer science)|parameters]] for commands. In executing a cmdlet, the job of binding the argument value to the parameter is done by PowerShell itself, but for external executables, arguments are parsed by the external executable independently of PowerShell interpretation.<ref>{{Cite web|last=Wheeler|first=Sean|date=September 7, 2021|title=about Parsing - PowerShell|url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing?view=powershell-7.2#passing-arguments-to-native-commands|access-date=December 5, 2021|website=Microsoft Docs}}</ref> |
|||
The implementation of these cmdlet classes can refer to any [[.NET Framework|.NET]] [[API]] and may be in any [[List of CLI languages|.NET language]]. In addition, PowerShell makes certain APIs available, such as <code>WriteObject()</code>, which is used to access PowerShell-specific functionality, such as writing resultant objects to the pipeline. Cmdlets can use .NET data access [[API]]s directly or use the PowerShell infrastructure of PowerShell ''Providers'', which make data stores addressable using unique [[Path (computing)|paths]]. Data stores are exposed using drive letters, and hierarchies within them, addressed as directories. Windows PowerShell ships with providers for the [[file system]], [[Windows Registry|registry]], the [[Public key certificate|certificate]] store, as well as the namespaces for command aliases, variables, and functions.<ref>{{cite web | url = http://technet.microsoft.com/en-us/library/dd347723.aspx | title = Windows PowerShell Providers | accessdate = 2010-10-14}}</ref> Windows PowerShell also includes various cmdlets for managing various [[Microsoft Windows|Windows]] systems, including the [[file system]], or using [[Windows Management Instrumentation]] to control [[List of Microsoft Windows components|Windows components]]. Other applications can register cmdlets with PowerShell, thus allowing it to manage them, and, if they enclose any datastore (such as databases), they can add specific providers as well. |
|||
=== Extended Type System === |
|||
In PowerShell V2, a more portable version of Cmdlets called Modules have been added. The PowerShell V2 release notes state, "Modules allow script developers and administrators to partition and organize their Windows PowerShell code in self-contained, reusable units. Code from a module executes in its own self-contained context and does not affect the state outside of the module. Modules also enable you to define a restricted runspace environment by using a script." |
|||
The PowerShell ''Extended Type System'' (''ETS'') is based on the .NET type system, but with extended semantics (for example, propertySets and third-party extensibility). For example, it enables the creation of different views of objects by exposing only a subset of the data fields, properties, and methods, as well as specifying custom formatting and sorting behavior. These views are mapped to the original object using [[XML]]-based configuration files.<ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714419.aspx | title = Windows PowerShell Extended Type System | access-date = November 28, 2007}}</ref> |
|||
=== |
=== Cmdlets === |
||
Cmdlets are specialized commands in the PowerShell environment that implement specific functions. These are the native commands in the PowerShell stack. Cmdlets follow a ''Verb''-''Noun'' naming pattern, such as ''Get-ChildItem'', which makes it [[self-documenting code]].<ref name="cmdlets">{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714395.aspx | title = Windows PowerShell Cmdlets | access-date = November 28, 2007}}</ref> Cmdlets output their results as objects and can also receive objects as input, making them suitable for use as recipients in a pipeline. If a cmdlet outputs multiple objects, each object in the collection is passed down through the entire pipeline before the next object is processed.<ref name="cmdlets" /> |
|||
PowerShell, like Unix/Linux based shells, implements a pipeline. This pipeline enables the output of one cmdlet to be piped as input to another cmdlet. For example, the output of the Get-Process cmdlet can be piped to the Sort-Object cmdlet (e.g. to sort the objects by handle count) and then to the Where-Object to filter any process that has say less than 1 MB of paged memory, then finally to the Select-Object cmdlet to select just the first 10 (i.e. the 10 processes based on handle count). |
|||
Cmdlets are specialized .NET [[class (computing)|classes]], which the PowerShell [[Runtime system|runtime]] instantiates and invokes at [[Runtime (program lifecycle phase)|execution time]]. Cmdlets derive either from <code>Cmdlet</code> or from <code>PSCmdlet</code>, the latter being used when the cmdlet needs to interact with the PowerShell runtime.<ref name="cmdlets" /> These base classes specify certain methods – <code>BeginProcessing()</code>, <code>ProcessRecord()</code> and <code>EndProcessing()</code> – which the cmdlet's implementation overrides to provide the functionality. Whenever a cmdlet runs, PowerShell invokes these methods in sequence, with <code>ProcessRecord()</code> being called if it receives pipeline input.<ref name="firstcmdlet">{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714622.aspx | title = Creating Your First Cmdlet | access-date = November 28, 2007}}</ref> If a collection of objects is piped, the method is invoked for each object in the collection. The class implementing the cmdlet must have one .NET [[Attribute (computing)|attribute]] – <code>CmdletAttribute</code> – which specifies the verb and the noun that make up the name of the cmdlet. Common verbs are provided as an [[enumerated type|enum]].<ref>{{cite web |title= Get-Verb |url= https://technet.microsoft.com/en-us/library/hh852690.aspx |website= [[Microsoft TechNet|TechNet]] |publisher= [[Microsoft]] |date= May 8, 2014}}</ref><ref>{{cite web |title= Cmdlet Overview |url= https://msdn.microsoft.com/en-us/library/ms714395%28v=vs.85%29.aspx |website= [[MSDN]] |publisher= [[Microsoft]] |date= May 8, 2014}}</ref> |
|||
While Unix/Linux systems have long employed the concept of pipelines, PowerShell differs in what is passed between stages in the pipeline. In Unix the output of one command is piped to the next stage of the pipeline typically as raw text. With PowerShell, the pipeline consists of .NET Objects. Using objects eliminates the need to parse arbitrary text output from one command to extract data since all objects export a consistent interface.<ref>[http://technet.microsoft.com/en-us/library/ee176927.aspx Windows PowerShell Owner's Manual: Piping and the Pipeline in Windows PowerShell]</ref> |
|||
If a cmdlet receives either pipeline input or command-line parameter input, there must be a corresponding [[property (programming)|property]] in the class, with a [[mutator method|mutator]] implementation. PowerShell invokes the mutator with the parameter value or pipeline input, which is saved by the mutator implementation in class variables. These values are then referred to by the methods which implement the functionality. Properties that map to command-line parameters are marked by <code>ParameterAttribute</code><ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714663.aspx | title = Adding parameters That Process Command Line Input | access-date = November 28, 2007}}</ref> and are set before the call to <code>BeginProcessing()</code>. Those which map to pipeline input are also flanked by <code>ParameterAttribute</code>, but with the <code>ValueFromPipeline</code> attribute parameter set.<ref>{{cite web | url = http://msdn2.microsoft.com/en-us/library/ms714597.aspx | title = Adding parameters That Process Pipeline Input | access-date = November 28, 2007}}</ref> |
|||
===Scripting=== |
|||
Windows PowerShell includes a [[dynamically typed]] [[scripting language]] which can implement complex operations using cmdlets [[imperative programming|imperatively]]. The scripting language supports variables, functions, branching (<code>[[conditional (programming)|if-then-else]]</code>), loops (<code>[[while loop|while]]</code>, <code>[[do while loop|do]]</code>, <code>[[for loop|for]]</code>, and <code>[[foreach]]</code>), structured error/exception handling and [[closure (computer science)|closures]]/[[lambda expressions]], as well as integration with .NET. Variables in PowerShell scripts have names that start with <code>$</code>; they can be assigned any value, including the output of cmdlets. While the language is untyped, internally the variables are stored with their types, which can be either [[primitive type]]s or objects. Strings can be enclosed either in single quotes or in double quotes: when using double quotes, variables will be expanded even if they are inside the quotation marks. According to the variable syntax, if the path to a file is enclosed in braces preceded by a dollar sign (as in <code>${C:\foo.txt}</code>), it refers to the contents of the file. If it is used as an [[Value (computer science)|L-value]], anything assigned to it will be written to the file. When used as an [[Value (computer science)|R-value]], it will be read from the file. If an object is assigned, it is serialized before storing it. |
|||
The implementation of these cmdlet classes can refer to any [[.NET Framework|.NET]] [[API]] and may be in any [[List of CLI languages|.NET language]]. In addition, PowerShell makes certain APIs available, such as <code>WriteObject()</code>, which is used to access PowerShell-specific functionality, such as writing resultant objects to the pipeline. Cmdlets can use .NET data access [[API]]s directly or use the PowerShell infrastructure of PowerShell ''Providers'', which make data stores addressable using unique [[Path (computing)|paths]]. Data stores are exposed using [[drive letter assignment|drive letters]], and hierarchies within them, addressed as directories. Windows PowerShell ships with providers for the [[file system]], [[Windows Registry|registry]], the [[public key certificate|certificate]] store, as well as the [[namespace]]s for command aliases, variables, and functions.<ref>{{cite web | url = https://technet.microsoft.com/en-us/library/dd347723.aspx | title = Windows PowerShell Providers | access-date = October 14, 2010}}</ref> Windows PowerShell also includes various cmdlets for managing various [[Microsoft Windows|Windows]] systems, including the [[file system]], or using [[Windows Management Instrumentation]] to control [[List of Microsoft Windows components|Windows components]]. Other applications can register cmdlets with PowerShell, thus allowing it to manage them, and, if they enclose any datastore (such as a database), they can add specific providers as well.{{citation needed|date=May 2013}} |
|||
Object members can be accessed using <code>.</code> notation, as in C# syntax. PowerShell provides special variables, such as <code>$args</code>, which is an array of all the command line arguments passed to a function from the command line, and <code>$_</code>, which refers to the current object in the pipeline.<ref>{{cite web | url = http://www.computerperformance.co.uk/powershell/powershell_variables.htm | title = Introduction to Windows PowerShell's Variables | accessdate = 2007-11-28}}</ref> PowerShell also provides [[Array data type|array]]s and [[associative array]]s. The PowerShell scripting language also evaluates arithmetic expressions entered on the command line immediately, and it parses common abbreviations, such as GB, MB, and KB. |
|||
The number of cmdlets included in the base PowerShell install has generally increased with each version: |
|||
Using the <code>function</code> keyword, PowerShell provides for the creation of functions, which can take parameters. A common problem for people new to PowerShell is that function arguments are separated by spaces, not commas: |
|||
{| class="wikitable sortable" |
|||
#<code>''<function> <param1> <param2>''</code>: Calls the function with two arguments. (These arguments may be bound to parameters declared in the function definition or accessed by position from the $args array.) |
|||
|- |
|||
#<code>''<function>(<param1>, <param2>)''</code>: Calls the function with a single argument, a two element array. |
|||
! Version |
|||
! data-sort-type="number" | Cmdlets |
|||
! Ref |
|||
|- |
|||
|Windows PowerShell 1.0 |
|||
|{{right|129}} || <ref>{{Cite web|url=https://social.technet.microsoft.com/wiki/contents/articles/13769.powershell-1-0-cmdlets.aspx|title=PowerShell 1.0 Cmdlets|last1=Yoshizawa|first1=Tomoaki|last2=Ramos|first2=Durval|date=September 29, 2012|website=TechNet Articles|publisher=Microsoft}}</ref> |
|||
|- |
|||
|Windows PowerShell 2.0 |
|||
|{{right|632}} || <ref>{{Cite web|url=https://social.technet.microsoft.com/wiki/contents/articles/13876.powershell-2-0-cmdlets.aspx|title=PowerShell 2.0 Cmdlets|last=Yoshizawa|first=Tomoaki|date=July 10, 2012|website=TechNet Articles|publisher=Microsoft}}</ref> |
|||
|- |
|||
|Windows PowerShell 3.0 |
|||
|{{right|about 1,000}} || <ref>{{Cite book|last=Wilson|first=Ed|title=Windows Powershell 3.0 Step by Step|date=2013|publisher=[[Microsoft Press]]|isbn=978-0-7356-7000-6|location=Sebastopol, California|chapter=1: Overview of Windows PowerShell 3.0|oclc=829236530|quote=Windows PowerShell 3.0 comes with about 1,000 cmdlets on Windows 8|chapter-url=https://www.microsoftpressstore.com/articles/article.aspx?p=2201304}}</ref> |
|||
|- |
|||
|Windows PowerShell 4.0 |
|||
| {{dunno}} || |
|||
|- |
|||
|Windows PowerShell 5.0 |
|||
|{{right|about 1,300}} || <ref>{{Cite book|last=Wilson|first=Ed|title=Windows PowerShell Step by Step|publisher=[[Microsoft Press]]|isbn=978-1-5093-0043-3|edition=Third|location=Redmond, Washington|chapter=1: Overview of Windows PowerShell 5.0|year=2015|oclc=927112976|quote=Windows PowerShell 5.0 comes with about 1,300 cmdlets on Windows 10|chapter-url=https://www.microsoftpressstore.com/articles/article.aspx?p=2449029}}</ref> |
|||
|- |
|||
|Windows PowerShell 5.1 |
|||
|{{right|1,586}} || {{Citation needed|date=April 2020}} |
|||
|- |
|||
|PowerShell Core 6.0 |
|||
| {{dunno}} || |
|||
|- |
|||
|PowerShell Core 6.1 |
|||
| {{dunno}} || |
|||
|- |
|||
|PowerShell Core 6.2 |
|||
| {{dunno}} || |
|||
|- |
|||
|PowerShell 7.0 |
|||
|{{right|1,507}} || {{Citation needed|date=April 2020}} |
|||
|- |
|||
|PowerShell 7.1 |
|||
| {{dunno}} || |
|||
|- |
|||
|PowerShell 7.2 |
|||
| {{dunno}} || |
|||
|- |
|||
|PowerShell 7.4 |
|||
|{{right|1,656}} || |
|||
|} |
|||
Cmdlets can be added into the shell through snap-ins (deprecated in v2) and modules; users are not limited to the cmdlets included in the base PowerShell installation. |
|||
PowerShell allows any .NET methods to be called by providing their namespaces enclosed in brackets (<code>[]</code>), and then using a pair of colons (<code>::</code>) to indicate the static method.<ref name="dotnet">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/05/TestRun/default.aspx | title = Lightweight Testing with Windows PowerShell | accessdate = 2007-11-28}}</ref> For example, |
|||
<code>[System.Console]::WriteLine("PowerShell")</code>. |
|||
Objects are created using the <code>New-Object</code> cmdlet. Calling methods of .NET objects is accomplished by using the regular <code>.</code> notation.<ref name="dotnet"/> |
|||
=== Pipeline === |
|||
For error handling, PowerShell provides a .NET-based [[Exception handling syntax|exception handling]] mechanism. In case of errors, objects containing information about the error (<code>Exception</code> object) are thrown, which are caught using the <code>trap</code> keyword. However, the action-or-error is configurable; in case of an error, PowerShell can be configured to silently resume execution, without trapping the exception.<ref>{{cite web | url = http://huddledmasses.org/trap-exception-in-powershell | title = <nowiki>Trap [Exception] { “In PowerShell” }</nowiki> | accessdate = 2007-11-28}}</ref> |
|||
PowerShell implements the concept of a ''[[pipeline (computing)|pipeline]]'', which enables piping the output of one cmdlet to another cmdlet as input. As with [[pipeline (Unix)|Unix pipelines]], PowerShell pipelines can construct complex commands, using the <code>|</code> operator to connect stages. However, the PowerShell pipeline differs from Unix pipelines in that stages execute ''within'' the PowerShell runtime rather than as a set of processes coordinated by the [[operating system]]. Additionally, structured .NET objects, rather than [[bitstream|byte streams]], are passed from one stage to the next. Using [[object (computer science)|objects]] and executing stages within the PowerShell runtime eliminates the need to [[serialization (computing)|serialize]] data structures, or to extract them by explicitly [[parser|parsing]] text output.<ref>{{cite web |url= https://technet.microsoft.com/en-us/library/ee176927.aspx |title= Windows PowerShell Owner's Manual: Piping and the Pipeline in Windows PowerShell |work= [[Microsoft TechNet|TechNet]] |publisher= [[Microsoft]] |access-date= September 27, 2011}}</ref> An object can also [[Encapsulation (computer programming)|encapsulate]] certain functions that work on the contained data, which become available to the recipient command for use.<ref>{{cite web | url = http://www.microsoft.com/technet/technetmag/issues/2007/07/PowerShell/default.aspx | title = Windows PowerShell – Rethinking the Pipeline |first= Don |last= Jones|year= 2008|work= [[Microsoft TechNet]] |publisher= [[Microsoft]] | access-date = November 28, 2007}}</ref><ref>{{cite web|url= http://msdn2.microsoft.com/en-us/library/aa347685.aspx |title= Windows PowerShell Object Concepts |access-date= November 28, 2007 |url-status= dead |archive-url= https://web.archive.org/web/20070819233213/http://msdn2.microsoft.com/en-us/library/aa347685.aspx |archive-date= August 19, 2007 }}</ref> For the last cmdlet in a pipeline, PowerShell automatically pipes its output object to the <code>Out-Default</code> cmdlet, which transforms the objects into a stream of format objects and then renders those to the screen.<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2006/04/30/586973.aspx | title = How PowerShell Formatting and Outputting REALLY works| access-date = November 28, 2007}}</ref><ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2006/06/21/641738.aspx | title = More – How does PowerShell formatting really work? | access-date = November 28, 2007}}</ref> |
|||
Because all PowerShell objects are .NET objects, they share a <code>.ToString()</code> method, which retrieves the text representation of the data in an object. In addition, PowerShell allows formatting definitions to be specified, so the text representation of objects can be customized by choosing which data elements to display, and in what manner. However, in order to maintain [[backward compatibility]], if an external executable is used in a pipeline, it receives a text stream representing the object, instead of directly integrating with the PowerShell type system.<ref>{{cite web|title= about_Pipelines|url= https://technet.microsoft.com/en-us/library/hh847902.aspx|website= [[Microsoft TechNet|TechNet]] | publisher= [[Microsoft]]|date= May 8, 2014}}</ref><ref>{{cite web|title= about_Objects|url= https://technet.microsoft.com/en-us/library/hh847810.aspx|website= [[Microsoft TechNet|TechNet]] |publisher= [[Microsoft]]|date= May 8, 2014}}</ref><ref name=about_Format.ps1xml>{{cite web|title= about_Format.ps1xml|url= https://technet.microsoft.com/en-us/library/hh847831.aspx|website= [[Microsoft TechNet|TechNet]]|publisher= [[Microsoft]]|date= May 8, 2014}}</ref> |
|||
Scripts written using PowerShell can be made to persist across sessions in a <code>.ps1</code> file. Later, either the entire script or individual functions in the script can be used. Scripts and functions are used analogously with cmdlets, in that they can be used as commands in pipelines, and parameters can be bound to them. Pipeline objects can be passed between functions, scripts, and cmdlets seamlessly. However, script execution is disabled by default and must be enabled explicitly.<ref>{{cite web | url = http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/run.mspx | title = Running Windows PowerShell Scripts | accessdate = 2007-11-28}}</ref> PowerShell scripts can be [[code signing|signed]] to verify their integrity, and are subject to [[Code Access Security]]. |
|||
=== Scripting === |
|||
The PowerShell scripting language supports [[binary prefix]] notation similar to the [[scientific notation]] supported by many programming languages in the C-family. |
|||
Windows PowerShell includes a [[dynamically typed]] [[scripting language]] which can implement complex operations using cmdlets [[imperative programming|imperatively]]. The scripting language supports variables, functions, branching (<code>[[conditional (programming)|if-then-else]]</code>), loops (<code>[[while loop|while]]</code>, <code>[[do while loop|do]]</code>, <code>[[for loop|for]]</code>, and <code>[[foreach]]</code>), structured error/exception handling and [[closure (computer science)|closures]]/[[anonymous function|lambda expressions]],<ref name="lambda1">{{cite web | url = http://defndo.com/powershell-code-blocks-and-anonymous-functions/ | title = Anonymous Functions and Code Blocks in PowerShell | access-date = January 21, 2012}}</ref> as well as integration with .NET. Variables in PowerShell scripts are prefixed with <code>$</code>. Variables can be assigned any value, including the output of cmdlets. Strings can be enclosed either in single quotes or in double quotes: when using double quotes, variables will be expanded even if they are inside the quotation marks. Enclosing the path to a file in braces preceded by a dollar sign (as in <code>${C:\foo.txt}</code>) creates a reference to the contents of the file. If it is used as an [[Value (computer science)|L-value]], anything assigned to it will be written to the file. When used as an [[Value (computer science)|R-value]], the contents of the file will be read. If an object is assigned, it is serialized before being stored.{{citation needed|date=May 2013}} |
|||
Object members can be accessed using <code>.</code> notation, as in C# syntax. PowerShell provides special variables, such as <code>$args</code>, which is an array of all the command-line arguments passed to a function from the command line, and <code>$_</code>, which refers to the current object in the pipeline.<ref>{{cite web | url = http://www.computerperformance.co.uk/powershell/powershell_variables.htm | title = Introduction to Windows PowerShell's Variables | access-date = November 28, 2007}}</ref> PowerShell also provides [[array data type|arrays]] and [[associative array]]s. The PowerShell scripting language also evaluates arithmetic expressions entered on the command line immediately, and it parses common abbreviations, such as GB, MB, and KB.<ref>{{cite web|title= Byte Conversion|url= https://technet.microsoft.com/en-us/library/ee692684.aspx|work= Windows PowerShell Tip of the Week|date= October 22, 2009|access-date= November 15, 2013}}</ref><ref>{{cite web|title= Converting to size units (KB, MB, GB, TB, and PB) without using PowerShell multipliers|url= http://www.powershellmagazine.com/2013/05/20/converting-to-size-units-kb-mbgbtb-and-pb-without-using-powershell-multipliers/|work= PowerShell Magazine|author= Ravikanth|date= May 20, 2013}}</ref> |
|||
===Hosting=== |
|||
Another use of PowerShell is being embedded in a management application, which then uses the PowerShell runtime to implement the management functionality. For this, PowerShell provides a [[managed code|managed]] hosting [[API]]. Via the APIs, the application can instantiate a ''runspace'' (one instantiation of the PowerShell runtime), which runs in the application's [[process (computing)|process]] and is exposed as a <code>Runspace</code> object.<ref name="how"/> The state of the runspace is encased in a <code>SessionState</code> object. When the runspace is created, the Windows PowerShell runtime initializes the instantiation, including initializing the providers and enumerating the cmdlets, and updates the <code>SessionState</code> object accordingly. The Runspace then must be opened for either synchronous processing or asynchronous processing. After that it can be used to execute commands. |
|||
Using the <code>function</code> keyword, PowerShell provides for the creation of functions. A simple function has the following general look:<ref name=about_Functions /> |
|||
To execute a command, a pipeline (represented by a <code>Pipeline</code> object) must be created and associated with the runspace. The pipeline object is then populated with the cmdlets that make up the pipeline. For sequential operations (as in a PowerShell script), a Pipeline object is created for each statement and nested inside another Pipeline object.<ref name="how"/> When a pipeline is created, Windows PowerShell invokes the pipeline processor, which resolves the cmdlets into their respective [[.NET assembly|assemblies]] (the ''command processor'') and adds a reference to them to the pipeline, and associates them with an <code>InputPipe</code>, <code>Outputpipe</code> and <code>ErrorOutputPipe</code> objects, to represent the connection with the pipeline. The types are verified and parameters bound using [[Reflection (computer science)|reflection]].<ref name="how"/> Once the pipeline is set up, the host calls the <code>Invoke()</code> method to run the commands, or its asynchronous equivalent - <code>InvokeAsync()</code>. If the pipeline has the <code>Write-Host</code> cmdlet at the end of the pipeline, it writes the result onto the console screen. If not, the results are handed over to the host, which might either apply further processing or display it itself. |
|||
<syntaxhighlight lang="powershell">function name ([Type]$Param1, [Type]$Param2) { |
|||
# Instructions |
|||
} |
|||
</syntaxhighlight> |
|||
However, PowerShell allows for advanced functions that support named parameters, positional parameters, switch parameters and dynamic parameters.<ref name="about_Functions" /> |
|||
The hosting APIs are used by [[Microsoft Exchange Server]] 2007 to provide its management GUI. Each operation exposed in the GUI is mapped to a sequence of PowerShell commands (or pipelines). The host creates the pipeline and executes them. In fact, the interactive PowerShell console itself is a PowerShell host, which [[interpreter|interprets]] the scripts entered at command line and creates the necessary <code>Pipeline</code> objects and invokes them. |
|||
<syntaxhighlight lang="powershell" line="1">function Verb-Noun { |
|||
param ( |
|||
# Definition of static parameters |
|||
) |
|||
dynamicparam { |
|||
# Definition of dynamic parameters |
|||
} |
|||
begin { |
|||
# Set of instruction to run at the start of the pipeline |
|||
} |
|||
process { |
|||
# Main instruction sets, ran for each item in the pipeline |
|||
} |
|||
end { |
|||
# Set of instruction to run at the end of the pipeline |
|||
} |
|||
} |
|||
</syntaxhighlight> |
|||
The defined function is invoked in either of the following forms:<ref name=about_Functions>{{cite web|title= about_Functions|url= https://technet.microsoft.com/en-us/library/hh847829.aspx|work= [[Microsoft TechNet]]|publisher= [[Microsoft]]|access-date= November 15, 2013|date= October 17, 2013}}</ref> |
|||
===PowerShell 2.0=== |
|||
<syntaxhighlight lang="powershell"> |
|||
[[File:GPowerShell.PNG|thumb|right|Windows PowerShell ISE, with multiple open PowerShell sessions (''RunSpaces'') in the Windows PowerShell 2.0]] |
|||
name value1 value2 |
|||
Microsoft released PowerShell 2.0 with Windows 7 and Windows 2008 R2. Windows PowerShell 2.0 is installed by default on [[Windows Server 2008 R2]] and [[Windows 7]]. |
|||
Verb-Noun -Param1 value1 -Param2 value2 |
|||
<ref>[http://blogs.msdn.com/powershell/archive/2008/10/28/powershell-will-be-installed-by-default-on-windows-server-08-r2-ws08r2-and-windows-7-w7.aspx PowerShell will be installed by default on Windows Server 08 R2 (WS08R2) and Windows 7 (W7)! - Windows PowerShell Blog - Site Home - MSDN Blogs<!-- Bot generated title -->]</ref> For older platforms it is available via the Windows Management Framework.<ref>[http://support.microsoft.com/kb/968929 Microsoft Support Knowledge Base: Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)]</ref> PowerShell V2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.<ref>[http://blogs.msdn.com/powershell/archive/2008/10/29/574-reasons-why-we-are-so-proud-and-optimistic-about-w7-and-ws08r2.aspx 574 Reasons Why We Are So Proud and Optimistic About W7 and WS08R2 - Windows PowerShell Blog - Site Home - MSDN Blogs<!-- Bot generated title -->]</ref><ref>[http://channel9.msdn.com/pdc2008/ES24/]{{dead link|date=September 2010}}</ref> |
|||
</syntaxhighlight> |
|||
PowerShell allows any static .NET methods to be called by providing their namespaces enclosed in brackets (<code>[]</code>), and then using a pair of colons (<code>::</code>) to indicate the static method.<ref name="dotnet">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/05/TestRun/default.aspx | title = Lightweight Testing with Windows PowerShell | access-date = November 28, 2007}}</ref> For example:<syntaxhighlight lang="powershell"> |
|||
A non-exhaustive list of the new features included in PowerShell V2 is: |
|||
[Console]::WriteLine("PowerShell") |
|||
<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2007/11/06/what-s-new-in-ctp-of-powershell-2-0.aspx | title = What's New in CTP of PowerShell 2.0 | accessdate = 2007-11-28}}</ref> |
|||
</syntaxhighlight>There are dozens of ways to create objects in PowerShell. Once created, one can access the properties and instance methods of an object using the <code>.</code> notation.<ref name="dotnet" /> |
|||
<ref>{{cite web | url = http://www.microsoft.com/downloads/details.aspx?FamilyId=7C8051C2-9BFC-4C81-859D-0864979FA403&displaylang=en | title = Windows PowerShell V2 Community Technology Preview 2 (CTP2) - releaseNotes | accessdate = 2008-05-05}}{{dead link|date=September 2010}}</ref> |
|||
<ref>{{cite web | url = http://activexperts.com/admin/powershell/ps1vs2/ | title = Differences between PowerShell 1.0 and PowerShell 2.0 | accessdate = 2010-06-26}}</ref> |
|||
*'''PowerShell Remoting''': Using [[WS-Management]], PowerShell 2.0 allows scripts and cmdlets to be invoked on a remote machine or a large set of remote machines. |
|||
*'''Background Jobs''': Also called a ''PSJob'', it allows a command sequence (script) or pipeline to be invoked asynchronously. Jobs can be run on the local machine or on multiple remote machines. An interactive cmdlet in a PSJob blocks the execution of the job until user input is provided. |
|||
*'''Transactions''': Enable cmdlet and provider developers to perform [[Transaction processing|transactional operations]]. PowerShell 2.0 includes transaction cmdlets for starting, committing, and rolling back a ''PSTransaction'' as well as features to manage and direct the transaction to the participating cmdlet and provider operations. The PowerShell Registry provider supports transactions. |
|||
*'''ScriptCmdlets''': These are cmdlets written using the PowerShell scripting language. '''NOTE:''' The preferred name for script cmdlets is now Advanced Functions. |
|||
*'''SteppablePipelines''': This allows the user to control when the <code>BeginProcessing()</code>, <code>ProcessRecord()</code> and <code>EndProcessing()</code> functions of a cmdlet are called. |
|||
* '''Modules''': This allows script developers and administrators to organize and partition PowerShell scripts in self-contained, reusable units. Code from a [[Modular programming|module]] executes in its own self-contained context and does not affect the state outside of the module. Modules can define a restricted runspace environment by using a script. They have a persistent state as well as public and private members. |
|||
*'''Data Language''': A domain-specific subset of the PowerShell scripting language, that allows data definitions to be decoupled from the scripts and allow [[Internationalization and localization|localized]] string resources to be imported into the script at runtime (''Script Internationalization''). |
|||
*'''Script Debugging''': It allows [[breakpoint]]s to be set in a PowerShell script or function. Breakpoints can be set on lines, line & columns, commands and read or write access of variables. It includes a set of cmdlets to control the breakpoints via script. |
|||
*'''Eventing''': This feature allows listening, forwarding, and acting on management and system events. Eventing allows PowerShell hosts to be notified about state changes to their managed entities. It also enables PowerShell scripts to subscribe to ''ObjectEvents'', ''PSEvents'', and ''WmiEvents'' and process them synchronously and asynchronously. |
|||
*'''Windows PowerShell Integrated Scripting Environment (ISE)''': PowerShell 2.0 includes a GUI-based PowerShell host (formerly known as ''Graphical Windows PowerShell'') that provides integrated debugger, [[syntax highlighting]], tab completion and up to 8 PowerShell Unicode-enabled consoles (Runspaces) in a tabbed UI, as well as the ability to run only the selected parts in a script. |
|||
*'''Network File Transfer''': Native support for prioritized, throttled, and asynchronous transfer of files between machines using the [[Background Intelligent Transfer Service]] (BITS).<ref>[http://blogs.msdn.com/powershell/archive/2008/10/14/gogrid-snap-in-managing-cloud-services-with-powershell.aspx GoGrid Snap-in - Managing Cloud Services with PowerShell - Windows PowerShell Blog - Site Home - MSDN Blogs<!-- Bot generated title -->]</ref> |
|||
*'''New Cmdlets''': Including <code>Out-GridView</code>, which displays tabular data in the [[Windows Presentation Foundation|WPF]] [[Grid view|GridView]] object. |
|||
*'''New Operators''': <code>-Split</code>, <code>-Join</code>, and Splatting (<code>@</code>) operators. |
|||
*'''Exception Handling with Try-Catch-Finally''': Unlike other .NET languages, this allows multiple exception types for a single catch block. |
|||
*'''Nestable Here-Strings''': PowerShell [[Here document|Here-Strings]] have been improved and can now nest.<ref>[http://blogs.msdn.com/powershell/archive/2008/10/18/emit-xml.aspx Emit-XML - Windows PowerShell Blog - Site Home - MSDN Blogs<!-- Bot generated title -->]</ref> |
|||
*'''Block Comments''': PowerShell 2.0 supports block comments using <code><#</code> and <code>#></code> as delimiters.<ref>[http://blogs.msdn.com/powershell/archive/2008/06/14/block-comments-in-v2.aspx Block Comments in V2 - Windows PowerShell Blog - Site Home - MSDN Blogs<!-- Bot generated title -->]</ref> |
|||
*'''New APIs''': The new APIs range from handing more control over the PowerShell parser and runtime to the host, to creating and managing collection of Runspaces (''RunspacePools'') as well as the ability to create ''Restricted Runspaces'' which only allow a configured subset of PowerShell to be invoked. The new APIs also support participation in a Windows PowerShell managed transaction. |
|||
PowerShell accepts [[string (computer science)|strings]], both raw and [[escape character|escaped]]. A string enclosed between single [[quotation mark]]s is a raw string while a string enclosed between double quotation marks is an escaped string. PowerShell treats straight and curly quotes as equivalent.<ref>{{cite web|last1= Angelopoulos|first1= Alex|last2= Karen|first2= Bemowski|title= PowerShell Got Smart About Smart Quotes|url= http://windowsitpro.com/powershell/powershell-got-smart-about-smart-quotes|work= Windows IT Pro|publisher= [[Penton Media]]|access-date= November 15, 2013|date= December 4, 2007}}</ref> |
|||
==Comparison of cmdlets with similar commands== |
|||
The following table contains a selection of the cmdlets that ship with PowerShell noting the most similar commands in other well known command line interpreters. |
|||
The following list of special characters is supported by PowerShell:<ref>{{cite web |title=About Special Characters |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_special_characters?view=powershell-6 |date=June 8, 2017 |website=Microsoft |department=Powershell / Scripting |access-date=June 20, 2019}}</ref> |
|||
{| class="wikitable" style="width: 100%; text-align: center; font-size: small;" |
|||
|- |
|||
{| class="wikitable plainrowheaders" style="text-align: center; font-size: small;" |
|||
!Windows PowerShell<br/>(Cmdlet) |
|||
|+PowerShell special characters |
|||
![[cmd.exe]] / [[COMMAND.COM]]<br/>(MS-DOS, Windows, OS/2, etc.) |
|||
![[Bash (Unix shell)|Bash]]<br/>(Unix, BSD, Linux, Mac OS X etc.) |
|||
!Description |
|||
|- |
|- |
||
! scope="col" | Sequence |
|||
|Get-ChildItem |
|||
! scope="col" | Meaning |
|||
|gci, dir, ls |
|||
|[[dir (command)|dir]] |
|||
|[[ls]] |
|||
|List all files / directories in the (current) directory |
|||
|- |
|- |
||
! {{mono|`0}} |
|||
|Get-Content |
|||
|[[Null character|Null]] |
|||
|gc, type, cat |
|||
|[[type (command)|type]] |
|||
|[[cat (Unix)|cat]] |
|||
|Get the content of a file |
|||
|- |
|- |
||
! {{mono|`a}} |
|||
|Get-Command |
|||
|[[Bell character|Alert]] |
|||
|gcm |
|||
|[[help (command)|help]] |
|||
|[[which (Unix)|which]] |
|||
|List available commands |
|||
|- |
|- |
||
! {{mono|`b}} |
|||
|Get-Help |
|||
|[[Backspace]] |
|||
|help, man |
|||
|[[help (command)|help]] |
|||
|[[Manpage|man]] |
|||
|Help on commands |
|||
|- |
|- |
||
! {{mono|`e}} |
|||
|Clear-Host |
|||
|[[Escape character|Escape]] (since PowerShell 6) |
|||
|cls, clear |
|||
|[[cls (computing)|cls]] |
|||
|[[clear (Unix)|clear]] |
|||
|Clear the screen<ref group="Note" >Clear-Host is implemented as a predefined PowerShell function.</ref> |
|||
|- |
|- |
||
! {{mono|`f}} |
|||
|Copy-Item |
|||
|[[Page break|Form feed]] |
|||
|cpi, copy, cp |
|||
|[[copy (command)|copy]] |
|||
|[[cp (Unix)|cp]] |
|||
|Copy one or several files / a whole directory tree |
|||
|- |
|- |
||
! {{mono|`n}} |
|||
|Move-Item |
|||
|[[Newline]] |
|||
|mi, move, mv |
|||
|[[move (command)|move]] |
|||
|[[mv]] |
|||
|Move a file / a directory to a new location |
|||
|- |
|- |
||
! {{mono|`r}} |
|||
|Remove-Item |
|||
|[[Carriage return]] |
|||
|ri, del, erase, rmdir, rd, rm |
|||
|[[del (command)|del]], [[del (command)|erase]], [[rmdir]], [[rmdir|rd]] |
|||
|[[Rm (Unix)|rm]], rmdir |
|||
|Delete a file / a directory |
|||
|- |
|- |
||
! {{mono|`t}} |
|||
|Rename-Item |
|||
|[[Tab key|Horizontal tab]] |
|||
|rni, ren, mv |
|||
|[[ren (command)|ren]], [[ren (command)|rename]] |
|||
|[[mv]] |
|||
|Rename a file / a directory |
|||
|- |
|- |
||
! {{mono|`u{x}<nowiki/>}} |
|||
|Get-Location |
|||
|[[Unicode]] escape sequence (since PowerShell 6) |
|||
|gl, pwd |
|||
|[[cd (command)|cd]] |
|||
|[[pwd]] |
|||
|Display the current directory/present working directory. |
|||
|- |
|- |
||
! {{mono|`v}} |
|||
|Pop-Location |
|||
|[[Tab key|Vertical tab]] |
|||
|popd |
|||
|[[pushd and popd|popd]] |
|||
|popd |
|||
|Change the current directory to the directory most recently pushed onto the stack |
|||
|- |
|- |
||
! {{mono|--%}} |
|||
|Push-Location |
|||
|Treat any character from this point forward literally |
|||
|pushd |
|||
|[[pushd and popd|pushd]] |
|||
|pushd |
|||
|Push the current directory onto the stack |
|||
|- |
|||
|Set-Location |
|||
|sl, cd, chdir |
|||
|[[cd (command)|cd]], [[cd (command)|chdir]] |
|||
|cd |
|||
|Change the current directory |
|||
|- |
|||
|Tee-Object |
|||
|tee |
|||
|n/a |
|||
|[[tee (command)|tee]] |
|||
|Pipe input to a file or variable, then pass the input along the pipeline |
|||
|- |
|||
|Write-Output |
|||
|echo, write |
|||
|[[echo (command)|echo]] |
|||
|echo |
|||
|Print strings, variables etc. to standard output |
|||
|- |
|||
|Get-Process |
|||
|gps, ps |
|||
|tlist,<ref group="Note" name="Available tlist kill">Available in Windows NT4, Windows 98 Resource Kit, Windows 2000 Support Tools</ref> tasklist<ref group="Note" name="Available tasklist taskkill">Available in Windows XP Professional Edition and later</ref> |
|||
|[[Ps (Unix)|ps]] |
|||
|List all currently running processes |
|||
|- |
|||
|Stop-Process |
|||
|spps, kill |
|||
|[[kill (command)|kill]],<ref group="Note" name="Available tlist kill" /> taskkill<ref group="Note" name="Available tasklist taskkill" /> |
|||
|kill<ref group="Note" name="UNIX kill misnomer">Also used in UNIX to send a process any [[Signal (computing)|signal]], the "Terminate" signal is merely the default</ref> |
|||
|Stop a running process |
|||
|- |
|||
|Select-String |
|||
| |
|||
|[[find (command)|find]], [[findstr]] |
|||
|[[grep]] |
|||
|Print lines matching a pattern |
|||
|- |
|||
|Set-Variable |
|||
|sv, set |
|||
|[[Environment variable#DOS|set]] |
|||
|set |
|||
|Set the value of a variable / create a variable |
|||
|} |
|} |
||
---- |
|||
;Notes:{{reflist|group="Note" }} |
|||
For error handling, PowerShell provides a .NET-based [[Exception handling syntax|exception-handling]] mechanism. In case of errors, objects containing information about the error (<code>Exception</code> object) are thrown, which are caught using the <code>try ... catch</code> construct (although a <code>trap</code> construct is supported as well). PowerShell can be configured to silently resume execution, without actually throwing the exception; this can be done either on a single command, a single session or perpetually.<ref>{{cite web | url = http://huddledmasses.org/trap-exception-in-powershell | title = Trap [Exception] { "In PowerShell" } | access-date = November 28, 2007}}</ref> |
|||
==Examples== |
|||
Examples are provided first using the long-form canonical syntax and then using more terse UNIX-like and DOS-like aliases that are set up in the default configuration. |
|||
Scripts written using PowerShell can be made to persist across sessions in either a <code>.ps1</code> file or a <code>.psm1</code> file (the latter is used to implement a module). Later, either the entire script or individual functions in the script can be used. Scripts and functions operate analogously with cmdlets, in that they can be used as commands in pipelines, and parameters can be bound to them. Pipeline objects can be passed between functions, scripts, and cmdlets seamlessly. To prevent unintentional running of scripts, script execution is disabled by default and must be enabled explicitly.<ref>{{cite web | url = http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/run.mspx | title = Running Windows PowerShell Scripts | website = [[Microsoft]] | access-date = November 28, 2007}}</ref> Enabling of scripts can be performed either at system, user or session level. PowerShell scripts can be [[code signing|signed]] to verify their integrity, and are subject to [[Code Access Security]].<ref>{{cite web|title= about_Signing|url= https://technet.microsoft.com/en-us/library/hh847874.aspx|work= [[Microsoft TechNet]]|publisher= [[Microsoft]]|access-date= November 15, 2013|date= October 17, 2013}}</ref> |
|||
* Stop all processes that begin with the letter p: |
|||
PS> get-process p* | stop-process |
|||
The PowerShell scripting language supports [[binary prefix]] notation similar to the [[scientific notation]] supported by many programming languages in the C-family.<ref>{{Cite book|title=Windows PowerShell Quick Reference|author=Lee Holmes|publisher= O'Reilly Media|date=September 2006}}</ref> |
|||
PS> ps p* | kill |
|||
=== Hosting === |
|||
* Find the processes that use more than 1000 MB of memory and kill them: |
|||
One can also use PowerShell embedded in a management application, which uses the PowerShell runtime to implement the management functionality. For this, PowerShell provides a [[managed code|managed]] hosting [[API]]. Via the APIs, the application can instantiate a ''runspace'' (one instantiation of the PowerShell runtime), which runs in the application's [[process (computing)|process]] and is exposed as a <code>Runspace</code> object.<ref name="how" /> The state of the runspace is encased in a <code>SessionState</code> object. When the runspace is created, the Windows PowerShell runtime initializes the instantiation, including initializing the providers and enumerating the cmdlets, and updates the <code>SessionState</code> object accordingly. The Runspace then must be opened for either synchronous processing or asynchronous processing. After that it can be used to execute commands.{{citation needed|date=May 2013}} |
|||
PS> get-process | where-object { $_.WS -gt 1000MB } | stop-process |
|||
To execute a command, a pipeline (represented by a <code>Pipeline</code> object) must be created and associated with the runspace. The pipeline object is then populated with the cmdlets that make up the pipeline. For sequential operations (as in a PowerShell script), a Pipeline object is created for each statement and nested inside another Pipeline object.<ref name="how" /> When a pipeline is created, Windows PowerShell invokes the pipeline processor, which resolves the cmdlets into their respective [[assembly (CLI)|assemblies]] (the ''command processor'') and adds a reference to them to the pipeline, and associates them with <code>InputPipe</code>, <code>OutputPipe</code> and <code>ErrorOutputPipe</code> objects, to represent the connection with the pipeline. The types are verified and parameters bound using [[Reflection (computer science)|reflection]].<ref name="how" /> Once the pipeline is set up, the host calls the <code>Invoke()</code> method to run the commands, or its asynchronous equivalent, <code>InvokeAsync()</code>. If the pipeline has the <code>Write-Host</code> cmdlet at the end of the pipeline, it writes the result onto the console screen. If not, the results are handed over to the host, which might either apply further processing or display the output itself.{{citation needed|date=May 2013}} |
|||
PS> ps | ? { $_.WS -gt 1000MB } | kill |
|||
[[Microsoft Exchange Server]] 2007 uses the hosting APIs to provide its management GUI. Each operation exposed in the GUI is mapped to a sequence of PowerShell commands (or pipelines). The host creates the pipeline and executes them. In fact, the interactive PowerShell console itself is a PowerShell host, which [[interpreter|interprets]] the scripts entered at command line and creates the necessary <code>Pipeline</code> objects and invokes them.{{citation needed|date=May 2013}} |
|||
* Calculate the number of bytes in the files in a directory: |
|||
PS> get-childitem | measure-object -property length -sum |
|||
== Desired State Configuration == |
|||
PS> ls | measure length -s |
|||
DSC allows for declaratively specifying how a software environment should be configured.<ref>{{cite web|url=https://msdn.microsoft.com/en-us/powershell/dsc/overview|title=Windows PowerShell Desired State Configuration Overview|last=eslesar|website=msdn.microsoft.com|date=May 23, 2023 }}</ref> |
|||
Upon running a ''configuration'', DSC will ensure that the system gets the state described in the configuration. DSC configurations are idempotent. The ''Local Configuration Manager'' (LCM) periodically polls the system using the control flow described by ''resources'' (imperative pieces of DSC) to make sure that the state of a configuration is maintained. |
|||
PS> dir | measure length -s |
|||
== Versions == |
|||
* Determine whether a specific process is no longer running: |
|||
Initially using the code name "Monad", PowerShell was first shown publicly at the Professional Developers Conference in October 2003 in Los Angeles. All major releases are still supported, and each major release has featured backwards compatibility with preceding versions. |
|||
PS> $processToWatch = get-process notepad |
|||
PS> $processToWatch.WaitForExit() |
|||
=== Windows PowerShell 1.0 === |
|||
PS> (ps notepad).WaitForExit() |
|||
[[File:Windows PowerShell 1.0 PD.png|thumb|Windows PowerShell 1.0 session using the [[Windows Console]]]] |
|||
PowerShell 1.0 was released in November 2006 for [[Windows XP SP2]], [[Windows Server 2003 SP1]] and [[Windows Vista]].<ref>{{cite web |url=https://devblogs.microsoft.com/powershell/its-a-wrap-windows-powershell-1-0-released |title=It's a Wrap! Windows PowerShell 1.0 Released! |publisher=[[Microsoft]] |work=Windows PowerShell Blog |date=November 14, 2006 |first1=Leonard |last1=Chung |first2=Jeffrey |last2=Snover |first3=Arul |last3=Kumaravel }}</ref> It is an optional component of [[Windows Server 2008]]. |
|||
=== Windows PowerShell 2.0 === |
|||
* Change the case of a string from lower to upper: |
|||
[[File:GPowerShell.PNG|thumb|Windows PowerShell ISE v2.0 on [[Windows 7]], an [[integrated development environment]] for PowerShell scripts]] |
|||
PS> 'hello, world!'.ToUpper() |
|||
PowerShell 2.0 is integrated with [[Windows 7]] and [[Windows Server 2008 R2]]<ref>{{cite web |url=http://blogs.msdn.com/powershell/archive/2008/10/28/powershell-will-be-installed-by-default-on-windows-server-08-r2-ws08r2-and-windows-7-w7.aspx |title=PowerShell will be installed by default on Windows Server 08 R2 (WS08R2) and Windows 7 (W7)! |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=October 28, 2008 |access-date=September 27, 2011}}</ref> and is released for [[Windows XP]] with Service Pack 3, [[Windows Server 2003]] with Service Pack 2, and [[Windows Vista]] with Service Pack 1.<ref>{{cite web |
|||
| url = http://blogs.msdn.com/powershell/archive/2009/10/27/windows-management-framework-is-here.aspx |
|||
| title = Windows Management Framework is here! |
|||
| date = October 27, 2009 |
|||
| access-date = October 30, 2009 |
|||
}}</ref><ref>{{cite web|url=http://support.microsoft.com/kb/968929 |title=Microsoft Support Knowledge Base: Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) |publisher=Support.microsoft.com |date=September 23, 2011 |access-date=September 27, 2011}}</ref> |
|||
PowerShell v2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.<ref>{{cite web |url=http://blogs.msdn.com/powershell/archive/2008/10/29/574-reasons-why-we-are-so-proud-and-optimistic-about-w7-and-ws08r2.aspx |title=574 Reasons Why We Are So Proud and Optimistic About W7 and WS08R2 |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=October 29, 2008 |access-date=September 27, 2011}}</ref><ref>{{cite web |last=Snover |first=Jeffrey |title=PowerShell: Creating Manageable Web Services |url=http://channel9.msdn.com/pdc2008/ES24/ |date=2008 |archive-url=https://web.archive.org/web/20081013065033/http://channel9.msdn.com/pdc2008/ES24/ |archive-date=October 13, 2008 |access-date=July 19, 2015}}</ref> |
|||
* Insert the string 'ABC' after the first character in the word 'string' to have the result 'sABCtring': |
|||
PS> 'string'.Insert(1, 'ABC') |
|||
New features of PowerShell 2.0 include:<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2007/11/06/what-s-new-in-ctp-of-powershell-2-0.aspx | title = What's New in CTP of PowerShell 2.0 | access-date = November 28, 2007}}</ref><ref>{{cite web|url=http://www.microsoft.com/downloads/details.aspx?FamilyId=7C8051C2-9BFC-4C81-859D-0864979FA403&displaylang=en |title=Windows PowerShell V2 Community Technology Preview 2 (CTP2) – releaseNotes |website=[[Microsoft]] |access-date=May 5, 2008 |url-status=dead |archive-url=https://web.archive.org/web/20080506150324/http://www.microsoft.com/downloads/details.aspx?FamilyID=7c8051c2-9bfc-4c81-859d-0864979fa403&DisplayLang=en |archive-date=May 6, 2008 }}</ref><ref>{{cite web | url = http://activexperts.com/admin/powershell/ps1vs2/ | title = Differences between PowerShell 1.0 and PowerShell 2.0 | access-date = June 26, 2010 | archive-date = September 17, 2010 | archive-url = https://web.archive.org/web/20100917075605/http://activexperts.com/admin/powershell/ps1vs2/ | url-status = dead }}</ref> |
|||
* Download a specific RSS feed and show the titles of the 8 most recent entries: |
|||
* '''PowerShell remoting''': Using [[WS-Management]], PowerShell 2.0 allows scripts and cmdlets to be invoked on a remote machine or a large set of remote machines. |
|||
<source lang="text"> |
|||
* '''Background jobs''': Also called a ''PSJob'', it allows a command sequence (script) or pipeline to be invoked asynchronously. Jobs can be run on the local machine or on multiple remote machines. An interactive cmdlet in a PSJob blocks the execution of the job until user input is provided. |
|||
PS> $rssUrl = 'http://blogs.msdn.com/powershell/rss.aspx' |
|||
* '''Transactions''': Enable cmdlet and developers can perform [[transaction processing|transactional operations]]. PowerShell 2.0 includes transaction cmdlets for starting, committing, and rolling back a ''PSTransaction'' as well as features to manage and direct the transaction to the participating cmdlet and provider operations. The PowerShell Registry provider supports transactions. |
|||
PS> $blog = [xml](new-object System.Net.WebClient).DownloadString($rssUrl) |
|||
* '''Advanced functions''': These are cmdlets written using the PowerShell scripting language. Initially called "script cmdlets", this feature was later renamed "advanced functions".<ref>{{cite web |url=https://technet.microsoft.com/en-us/library/ff677563.aspx |title=Windows PowerShell: Writing Cmdlets in Script |last=Jones |first=Don |publisher=Microsoft |date=May 2010 |website=[[TechNet Magazine]]}}</ref> |
|||
PS> $blog.rss.channel.item | select title -first 8 |
|||
* '''SteppablePipelines''': This allows the user to control when the <code>BeginProcessing()</code>, <code>ProcessRecord()</code> and <code>EndProcessing()</code> functions of a cmdlet are called. |
|||
</source> |
|||
* '''Modules''': This allows script developers and administrators to organize and partition PowerShell scripts in self-contained, reusable units. Code from a [[Modular programming|module]] executes in its own self-contained context and does not affect the state outside the module. Modules can define a restricted runspace environment by using a script. They have a persistent state as well as public and private members. |
|||
<source lang="text"> |
|||
* '''Data language''': A domain-specific subset of the PowerShell scripting language that allows data definitions to be decoupled from the scripts and allows [[internationalization and localization|localized]] string resources to be imported into the script at runtime (''Script Internationalization''). |
|||
$x=new-object xml;$x.load('http://blogs.msdn.com/powershell/rss.aspx');$x.rss.channel.item|select title -f 8 |
|||
* '''Script debugging''': It allows [[breakpoint]]s to be set in a PowerShell script or function. Breakpoints can be set on lines, line & columns, commands and read or write access of variables. It includes a set of cmdlets to control the breakpoints via script. |
|||
</source> |
|||
* '''Eventing''': This feature allows listening, forwarding, and acting on management and system events. Eventing allows PowerShell hosts to be notified about state changes to their managed entities. It also enables PowerShell scripts to subscribe to ''ObjectEvents'', ''PSEvents'', and ''WmiEvents'' and process them synchronously and asynchronously. |
|||
* '''Windows PowerShell Integrated Scripting Environment (ISE)''': PowerShell 2.0 includes a GUI-based PowerShell host that provides integrated debugger, [[syntax highlighting]], tab completion and up to 8 PowerShell Unicode-enabled consoles (Runspaces) in a tabbed UI, as well as the ability to run only the selected parts in a script. |
|||
* '''Network file transfer''': Native support for prioritized, throttled, and asynchronous transfer of files between machines using the [[Background Intelligent Transfer Service]] (BITS).<ref>{{cite web |url=http://blogs.msdn.com/powershell/archive/2008/10/14/gogrid-snap-in-managing-cloud-services-with-powershell.aspx |title=GoGrid Snap-in – Managing Cloud Services with PowerShell |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=October 14, 2008 |access-date=September 27, 2011}}</ref> |
|||
* '''New cmdlets''': Including <code>Out-GridView</code>, which displays tabular data in the [[Windows Presentation Foundation|WPF]] [[Grid view|GridView]] object, on systems that allow it, and if ISE is installed and enabled. |
|||
* '''New operators''': <code>-Split</code>, <code>-Join</code>, and Splatting (<code>@</code>) operators. |
|||
* '''Exception handling with Try-Catch-Finally''': Unlike other .NET languages, this allows multiple exception types for a single catch block. |
|||
* '''Nestable Here-Strings''': PowerShell [[here document|Here-Strings]] have been improved and can now nest.<ref>{{cite web |url=http://blogs.msdn.com/powershell/archive/2008/10/18/emit-xml.aspx |title=Emit-XML |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=October 17, 2008 |access-date=September 27, 2011}}</ref> |
|||
* '''Block comments''': PowerShell 2.0 supports block comments using <code><#</code> and <code>#></code> as delimiters.<ref>{{cite web |url=http://blogs.msdn.com/powershell/archive/2008/06/14/block-comments-in-v2.aspx |title=Block Comments in V2 |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=June 14, 2008 |access-date=September 27, 2011}}</ref> |
|||
* '''New APIs''': The new APIs range from handing more control over the PowerShell parser and runtime to the host, to creating and managing collection of Runspaces (<code>RunspacePools</code>) as well as the ability to create ''Restricted Runspaces'' which only allow a configured subset of PowerShell to be invoked. The new APIs also support participation in a transaction managed by PowerShell |
|||
=== Windows PowerShell 3.0 === |
|||
* Sets $UserProfile to the value of the UserProfile environment variable |
|||
PowerShell 3.0 is integrated with [[Windows 8]] and with [[Windows Server 2012]]. Microsoft has also made PowerShell 3.0 available for [[Windows 7]] with Service Pack 1, for [[Windows Server 2008]] with Service Pack 1, and for [[Windows Server 2008 R2]] with Service Pack 1.<ref>{{cite web |
|||
PS> $UserProfile = $env:UserProfile |
|||
| url = http://tfl09.blogspot.co.uk/2012/08/powershell-version-3-is-rtm.html |
|||
| last = Lee |
|||
| first = Thomas |
|||
| title = PowerShell Version 3 is RTM! |
|||
| work = Under The Stairs |
|||
| date = August 13, 2012 |
|||
| access-date = August 13, 2012 |
|||
}}</ref><ref name="WMF3">{{cite web|title=Windows Management Framework 3.0|url=http://www.microsoft.com/en-us/download/details.aspx?id=34595|work=Download Center|publisher=[[Microsoft]]|access-date=November 8, 2012|date=September 4, 2012}}</ref> |
|||
PowerShell 3.0 is part of a larger package, [https://www.microsoft.com/en-in/download/details.aspx?id=34595 Windows Management Framework] 3.0 (WMF3), which also contains the [[WinRM]] service to support remoting.<ref name="WMF3" /> Microsoft made several [[Community Technology Preview]] releases of WMF3. An early community technology preview 2 (CTP 2) version of Windows Management Framework 3.0 was released on December 2, 2011.<ref>{{cite web |url=http://blogs.msdn.com/b/powershell/archive/2011/12/02/windows-management-framework-3-0-community-technology-preview-ctp-2-available-for-download.aspx |title=Windows Management Framework 3.0 Community Technology Preview (CTP) #2 Available for Download |work=Windows PowerShell Blog |publisher=[[Microsoft]] |date=December 2, 2011}}</ref> Windows Management Framework 3.0 was released for general availability in December 2012<ref>{{cite web |url=https://www.microsoft.com/en-us/download/details.aspx?id=34595|title=Windows Management Framework 3.0 |work=Download Center |publisher=[[Microsoft]] |date=December 3, 2012}}</ref> and is included with Windows 8 and Windows Server 2012 by default.<ref>{{cite web |url=https://msdn.microsoft.com/en-us/powershell/scripting/setup/windows-powershell-system-requirements |title=Windows PowerShell System Requirements |last=Jofre |first=JuanPablo |publisher=Microsoft |date=December 14, 2016 |website=Microsoft Developer Network |access-date=April 20, 2017}}</ref> |
|||
* Cast a .Net Namespace, and call a method exposed by the cast |
|||
<source lang="text"> |
|||
PS> [System.Windows.Forms.MessageBox]::Show('Hello, World!') |
|||
</source> |
|||
New features in PowerShell 3.0 include:<ref name="WMF3" /><ref>{{cite book|last=Honeycutt|first=Jerry|title=Introducing Windows 8: An Overview for IT Professionals|year=2012|publisher=[[Microsoft Press]]|location=Redmond, WA|isbn=978-0-7356-7050-1|url=http://blogs.msdn.com/b/microsoft_press/archive/2012/11/13/free-ebook-introducing-windows-8-an-overview-for-it-professionals-final-edition.aspx|editor-last=Woolley |editor-first=Valerie}}</ref>{{Rp|33–34}} |
|||
* Run a command line executable, with arguments. |
|||
* '''Scheduled jobs''': Jobs can be scheduled to run on a preset time and date using the [[Windows Task Scheduler]] infrastructure. |
|||
<source lang="text"> |
|||
* '''Session connectivity''': Sessions can be disconnected and reconnected. Remote sessions have become more tolerant of temporary network failures. |
|||
PS> [Array]$arguments = '-h', '15', 'www.google.com' |
|||
* '''Improved code writing''': [[Code completion]] (IntelliSense) and [[snippet (programming)|snippets]] are added. PowerShell ISE allows users to use dialog boxes to fill in parameters for PowerShell cmdlets. |
|||
PS> tracert $arguments |
|||
* '''Delegation support''': Administrative tasks can be delegated to users who do not have permissions for that type of task, without granting them perpetual additional permissions. |
|||
</source> |
|||
* '''Help update''': Help documentations can be updated via Update-Help command. |
|||
* '''Automatic module detection''': Modules are loaded implicitly whenever a command from that module is invoked. Code completion works for unloaded modules as well. |
|||
* '''New commands''': Dozens of new modules were added, including functionality to manage disks <code>get-WmiObject win32_logicaldisk</code>, volumes, firewalls, network connections, and printers, which had previously been performed via WMI.{{Explain|date=January 2014}} |
|||
=== Windows PowerShell 4.0 === |
|||
==File extensions== |
|||
PowerShell 4.0 is integrated with [[Windows 8.1]] and with [[Windows Server 2012 R2]]. Microsoft has also made PowerShell 4.0 available for [[Windows 7 SP1]], [[Windows Server 2008 R2]] SP1 and [[Windows Server 2012]].<ref>{{cite web|title=Windows Management Framework 4.0 is now available|url=http://blogs.msdn.com/b/powershell/archive/2013/10/25/windows-management-framework-4-0-is-now-available.aspx|publisher=[[Microsoft]]|access-date=November 4, 2013|date=October 24, 2013}}</ref> |
|||
* PS1 – Windows PowerShell shell script |
|||
* PS1XML – Windows PowerShell format and type definitions |
|||
New features in PowerShell 4.0 include: |
|||
* '''Desired State Configuration''':<ref>{{cite web|last=Levy|first=Shay|title=New Features in Windows PowerShell 4.0|url=http://www.powershellmagazine.com/2013/06/25/new-features-in-windows-powershell-4-0/|work=PowerShell Magazine|access-date=June 26, 2013|date=June 25, 2013}}</ref><ref>{{cite web|title=Desired State Configuration in Windows Server 2012 R2 PowerShell|url=http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/MDC-B302#fbid=sBK5uHH2bcL|work=[[Channel 9 (Microsoft)|Channel 9]]|publisher=[[Microsoft]]|access-date=June 26, 2013|date=June 3, 2013|archive-date=December 26, 2013|archive-url=https://web.archive.org/web/20131226224907/http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/MDC-B302#fbid=sBK5uHH2bcL|url-status=dead}}</ref><ref>{{cite web|last=Hall|first=Adrian|title=Thoughts from Microsoft TechEd North America|url=http://blogs.splunk.com/2013/06/07/thoughts-from-microsoft-teched-north-america/|work=Blogs: Tips & Tricks|publisher=[[Splunk]]|access-date=June 26, 2013|date=June 7, 2013}}</ref> Declarative language extensions and tools that enable the deployment and management of configuration data for systems using the [[DMTF]] management standards and [[WS-Management]] Protocol |
|||
* PSD1 – Windows PowerShell data file (for Version 2) |
|||
* '''New default execution policy''': On Windows Servers, the default execution policy is now <code>RemoteSigned</code>. |
|||
* PSM1 – Windows PowerShell module file (for Version 2) |
|||
* '''Save-Help''': Help can now be saved for modules that are installed on remote computers. |
|||
* '''Enhanced debugging''': The [[debugger]] now supports debugging workflows, remote script execution and preserving debugging sessions across PowerShell session reconnections. |
|||
* '''-PipelineVariable switch''': A new ubiquitous parameter to expose the current pipeline object as a variable for programming purposes |
|||
* '''Network diagnostics''' to manage physical and [[Hyper-V]]'s virtualized [[network switch]]es |
|||
* '''Where and ForEach''' method syntax provides an alternate method of filtering and iterating over objects. |
|||
=== Windows PowerShell 5.0 === |
|||
[[File:PowerShell 5.0 icon.png|thumb|128px|PowerShell 5.0 icon]] |
|||
Windows Management Framework (WMF) 5.0 RTM which includes PowerShell 5.0 was re-released to web on February 24, 2016, following an initial release with a severe bug.<ref>{{cite web|title=Windows Management Framework (WMF) 5.0 RTM packages has been republished|url=https://blogs.msdn.microsoft.com/powershell/2016/02/24/windows-management-framework-wmf-5-0-rtm-packages-has-been-republished/|website=Windows PowerShell Blog|publisher=[[Microsoft]]|date=February 24, 2016}}</ref> |
|||
Key features included: |
|||
* The new <code>class</code> [[reserved word|keyword]] that creates [[class (computer programming)|classes]] for [[object-oriented programming]] |
|||
* The new <code>enum</code> keyword that creates [[enumeration|enums]] |
|||
* <code>OneGet</code> cmdlets to support the [[Chocolatey (software package manager)|Chocolatey]] [[package management|package manager]]<ref>{{cite web|url=https://github.com/OneGet/oneget/wiki/Q-and-A|title=Q and A|work=GitHub|access-date=April 21, 2015}}</ref> |
|||
* Extending support for switch management to [[Data link layer|layer 2]] network switches.<ref name='Snover 2014-04-03'>{{cite web |title=Windows Management Framework V5 Preview |url=http://blogs.technet.com/b/windowsserver/archive/2014/04/03/windows-management-framework-v5-preview.aspx |work=blogs.technet.com |publisher=[[Microsoft]] |first=Jeffrey |last=Snover |date=April 3, 2014 |access-date=April 21, 2015 |archive-url=https://web.archive.org/web/20140630174828/http://blogs.technet.com/b/windowsserver/archive/2014/04/03/windows-management-framework-v5-preview.aspx |archive-date=June 30, 2014 |url-status=dead }}</ref> |
|||
* Debugging for PowerShell background jobs and instances of PowerShell hosted in other processes (each of which is called a "runspace") |
|||
* Desired State Configuration (DSC) Local Configuration Manager (LCM) version 2.0 |
|||
* DSC partial configurations |
|||
* DSC Local Configuration Manager meta-configurations |
|||
* Authoring of DSC resources using PowerShell classes |
|||
=== Windows PowerShell 5.1 === |
|||
It was released along with the [[Windows 10 Anniversary Update]]<ref>{{cite web|url=http://www.powershellmagazine.com/2016/08/02/pstip-new-powershell-commands-in-windows-10-anniversary-update/|title=#PSTip New PowerShell Commands in Windows 10 Anniversary Update|first=Jaap Brasser|last=says|date=August 2, 2016}}</ref> on August 2, 2016, and in [[Windows Server 2016]].<ref>{{cite web|url=https://blogs.technet.microsoft.com/ausoemteam/2016/09/04/whats-new-in-windows-server-2016-standard-edition-part-9-management-and-automation/|title=What's New In Windows Server 2016 Standard Edition Part 9 – Management And Automation|date=September 4, 2016 }}</ref> PackageManagement now supports proxies, PSReadLine now has ViMode support, and two new cmdlets were added: Get-TimeZone and Set-TimeZone. The LocalAccounts module allows for adding/removing local user accounts.<ref>{{cite web|url=https://technet.microsoft.com/en-us/library/mt651681.aspx|title=Microsoft.PowerShell.LocalAccounts Module|website=technet.microsoft.com|date=June 16, 2016 }}</ref> A preview for PowerShell 5.1 was released for Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2 on July 16, 2016,<ref>{{cite web|url=https://blogs.msdn.microsoft.com/powershell/2016/07/16/announcing-windows-management-framework-wmf-5-1-preview/|title=Announcing Windows Management Framework (WMF) 5.1 Preview|date=July 16, 2016}}</ref> and was released on January 19, 2017.<ref>{{cite web|url=https://www.microsoft.com/en-us/download/details.aspx?id=54616|title=WMF 5.1|website=Microsoft Download Center}}</ref> |
|||
PowerShell 5.1 is the first version to come in two editions of "Desktop" and "Core". The "Desktop" edition is the continuation of the traditional Windows PowerShell that runs on the .NET Framework stack. The "Core" edition runs on .NET Core and is bundled with Windows Server 2016 Nano Server. In exchange for smaller footprint, the latter lacks some features such as the cmdlets to manage clipboard or join a computer to a domain, WMI version 1 cmdlets, Event Log cmdlets and profiles.<ref name=":0" /> This was the final version of PowerShell made exclusively for Windows. Windows PowerShell 5.1 remains pre-installed on Windows 10, Windows 11 and Windows Server 2022, while the .NET PowerShell needs to be installed separately and can run side-by-side with Windows PowerShell.<ref>{{Cite web |date=2024-03-07 |title=What is Windows PowerShell? - PowerShell |url=https://learn.microsoft.com/en-us/powershell/scripting/what-is-windows-powershell?view=powershell-7.4 |access-date=2024-08-19 |website=Microsoft Learn |language=en-us}}</ref><ref>{{Cite web |date=2024-04-02 |title=Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell |url=https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4#using-powershell-7-side-by-side-with-windows-powershell-51 |access-date=2024-08-19 |website=Microsoft Learn |language=en-us}}</ref> |
|||
=== PowerShell Core 6 === |
|||
PowerShell Core 6.0 was first announced on August 18, 2016, when Microsoft unveiled PowerShell Core and its decision to make the product [[Cross-platform software|cross-platform]], independent of Windows, free and open source.<ref name="ars-opensource" /> It achieved [[general availability]] on January 10, 2018, for Windows, [[macOS]] and [[Linux]].<ref>{{cite web |last1=Aiello |first1=Joey |title=PowerShell Core 6.0: Generally Available (GA) and Supported! |url=https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/ |website=PowerShell Team Blog |publisher=Microsoft |access-date=June 11, 2018 |ref=1 |archive-url=https://archive.today/20180611172006/https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/ |archive-date=June 11, 2018 |date=January 11, 2018 |url-status=live }}</ref> It has its own support lifecycle and adheres to the Microsoft lifecycle policy that is introduced with Windows 10: Only the latest version of PowerShell Core is supported. Microsoft expects to release one minor version for PowerShell Core 6.0 every six months.<ref>{{cite web |last1=Aiello |first1=Joey |last2=Wheeler |first2=Sean |title=PowerShell Core Support Lifecycle |url=https://docs.microsoft.com/en-us/powershell/scripting/PowerShell-Core-Support?view=powershell-6 |website=Microsoft Docs |publisher=[[Microsoft]] |date=January 10, 2018 |access-date=January 11, 2018 |archive-date=November 16, 2018 |archive-url=https://web.archive.org/web/20181116013534/https://docs.microsoft.com/en-us/powershell/scripting/powershell-core-support?view=powershell-6 |url-status=dead }}</ref> |
|||
The most significant change in this version of PowerShell is the expansion to the other platforms. For Windows administrators, this version of PowerShell did not include any major new features. In an interview with the community on January 11, 2018, the PowerShell team was asked to list the top 10 most exciting things that would happen for a Windows IT professional who would migrate from Windows PowerShell 5.1 to PowerShell Core 6.0; in response, Angel Calvo of Microsoft could only name two: cross-platform and open-source.<ref>{{cite web|last1=Calvo|first1=Angel|title=Top 10 most exciting reasons to migrate|url=https://techcommunity.microsoft.com/t5/PowerShell-AMA/Top-10-most-exciting-reasons-to-migrate/m-p/143960#M25|website=PowerShell AMA|publisher=[[Microsoft]]|date=January 11, 2018}}</ref> PowerShell 6 changed to [[UTF-8]] as default encoding, with some exceptions.<ref>{{Cite web |last=sdwheeler |date=2023-08-03 |title=What's New in PowerShell Core 6.0 |url=https://learn.microsoft.com/en-us/previous-versions/powershell/scripting/whats-new/what-s-new-in-powershell-core-60?view=powershell-7.1 |access-date=2023-12-11 |website=learn.microsoft.com |language=en-us |quote=Default encoding is UTF-8 without a BOM except for New-ModuleManifest}}</ref> (PowerShell 7.4 changes more to UTF-8)<!-- |
|||
"PowerShell's default encoding varies depending on version: |
|||
* In PowerShell 6+, the default encoding is UTF-8 without BOM on all platforms. |
|||
* In Windows PowerShell, the default encoding is usually Windows-1252, which is an extension of latin-1 (also known as ISO 8859-1)."--><ref name="Windows-1252">{{Cite web |date=2023-11-29 |title=Understanding file encoding in VS Code and PowerShell - PowerShell |url=https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding?view=powershell-7.4 |access-date=2023-12-11 |website=learn.microsoft.com |language=en-us}}</ref> |
|||
==== 6.1 ==== |
|||
According to Microsoft, one of the new features of PowerShell 6.1 is "Compatibility with 1900+ existing cmdlets in Windows 10 and [[Windows Server 2019]]."<ref>{{cite web |title=Announcing PowerShell Core 6.1 |url=https://devblogs.microsoft.com/powershell/announcing-powershell-core-6-1/ |work=devblogs.microsoft.com |publisher=[[Microsoft]] |first=Joey |last=Aiello|date=September 13, 2018 |access-date=June 1, 2019}}</ref> Still, no details of these cmdlets can be found in the full version of the change log.<ref>{{Cite web|title=PowerShell/PowerShell|url=https://github.com/PowerShell/PowerShell|access-date=June 22, 2020|website=GitHub|language=en}}</ref> Microsoft later professes that this number was insufficient as PowerShell Core failed to replace Windows PowerShell 5.1 and gain traction on Windows.<ref name=":1" /> It was, however, popular on Linux.<ref name=":1" /> |
|||
==== 6.2 ==== |
|||
PowerShell Core 6.2 is focused primarily on performance improvements, bug fixes, and smaller cmdlet and language enhancements that improved developer productivity.<ref>{{cite web |title=General Availability of PowerShell Core 6.2 |url=https://devblogs.microsoft.com/powershell/general-availability-of-powershell-core-6-2/ |work=devblogs.microsoft.com |publisher=[[Microsoft]] |first=Steve |last=Lee |date=March 28, 2019 |access-date=June 1, 2019}}</ref> |
|||
=== PowerShell 7 === |
|||
PowerShell 7 is the replacement for PowerShell Core 6.x products as well as Windows PowerShell 5.1, which is the last supported Windows PowerShell version.<ref>{{cite web |title=Microsoft Releases PowerShell 7 Preview |url=https://redmondmag.com/articles/2019/05/30/powershell-7-preview-released.aspx |publisher=[[1105 Media Inc]] |first=Kurt |last=Mackie|date=May 30, 2019 |access-date=June 1, 2019}}</ref><ref name=":1">{{cite web |title=The Next Release of PowerShell – PowerShell 7 |url=https://devblogs.microsoft.com/powershell/the-next-release-of-powershell-powershell-7/ |publisher=[[Microsoft]] |first=Steve |last=Lee|date=April 5, 2019 |access-date=June 1, 2019}}</ref> The focus in development was to make PowerShell 7 a viable replacement for Windows PowerShell 5.1, i.e. to have near parity with Windows PowerShell in terms of compatibility with modules that ship with Windows.<ref>{{cite web |title=PowerShell 7 Road Map |url=https://devblogs.microsoft.com/powershell/powershell-7-road-map/ |work=devblogs.microsoft.com | publisher=[[Microsoft]] |first=Steve |last=Lee|date=May 30, 2019 |access-date=August 12, 2020}}</ref> |
|||
New features in PowerShell 7 include:<ref name="ps7p5">{{Cite web |url=https://devblogs.microsoft.com/powershell/powershell-7-preview-5/ |title=PowerShell 7 Preview 5 {{!}} PowerShell |date=October 23, 2019 |access-date=March 5, 2020 |archive-date=February 15, 2020 |archive-url=https://web.archive.org/web/20200215113601/https://devblogs.microsoft.com/powershell/powershell-7-preview-5/ |url-status=live }}</ref> |
|||
* The <code>-Parallel</code> switch for the <code>ForEach-Object</code> cmdlet to help handle parallel processing |
|||
* Near parity with Windows PowerShell in terms of compatibility with built-in Windows modules |
|||
* A new error view |
|||
* The <code>Get-Error</code> cmdlet |
|||
* Pipeline chaining operators (<code>&&</code> and <code>||</code>) that allow conditional execution of the next cmdlet in the pipeline |
|||
* The [[?:]] operator for [[ternary operation]] |
|||
* The <code>??</code> operator for [[Null coalescing operator|null coalescing]] |
|||
* The <code>??=</code> operator for null coalescing assignment |
|||
* Cross-platform <code>Invoke-DscResource</code> (experimental) |
|||
* Return of the <code>Out-GridView</code> cmdlet |
|||
* Return of the <code>-ShowWindow</code> switch for the <code>Get-Help</code> |
|||
==== PowerShell 7.2 ==== |
|||
PowerShell 7.2 is the next long-term support version of PowerShell, after version 7.0. It uses [[.NET]] 6.0 and features universal installer packages for Linux. On Windows, updates to PowerShell 7.2 and later come via the [[Microsoft Update]] service; this feature has been missing from PowerShell 6.0 through 7.1.<ref>{{Cite web|url=https://www.itsfoss.net/powershell-7-2/|title=PowerShell 7.2 is the new version of Microsoft's next-generation shell |website=itsfoss.net|date=November 12, 2021}}</ref> |
|||
==== PowerShell 7.3 ==== |
|||
This version includes some general Cmdlet updates and fixes, testing for framework dependent package in release pipeline as well as build and packaging improvements.<ref>{{Cite web |url=https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0 |title=Release v7.3.0 Release of PowerShell · PowerShell/PowerShell |website=[[GitHub]] |access-date=March 7, 2022 |archive-date=November 9, 2022 |archive-url=https://web.archive.org/web/20221109021444/https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0 |url-status=live }}</ref> |
|||
==== PowerShell 7.4 ==== |
|||
PowerShell 7.4 is based on [[.NET]] 8. And with that release webcmdlets default to [[UTF-8]] [[Character encoding|encoding]] (changing from [[ASCII]]-superset [[Windows-1252]] aka <!-- only for the web, otherwise not the same, and the former a superset--> [[ISO-8859-1]], that does not support [[Unicode]]).<ref>{{Cite web |title=Webcmdlets set default charset encoding to UTF8 by CarloToso · Pull Request #18219 · PowerShell/PowerShell |url=https://github.com/PowerShell/PowerShell/pull/18219 |access-date=2023-12-11 |website=GitHub |language=en}}</ref><ref name="Windows-1252" /> Previously UTF-8 was default for other, but not all, things. |
|||
== Comparison of cmdlets with similar commands == |
|||
The following table contains a selection of the cmdlets that ship with PowerShell, noting similar commands in other well-known command-line interpreters. Many of these similar commands come out-of-the-box defined as aliases within PowerShell, making it easy for people familiar with other common shells to start working. |
|||
{| class="wikitable plainrowheaders" style="width: 100%; text-align: center; font-size: small;" |
|||
|+Comparison of PowerShell cmdlets with internal and external commands of other command-line interpreters |
|||
|- |
|||
! scope="col" style=width:130px;| PowerShell (Cmdlet) |
|||
! scope="col" | PowerShell (Alias) |
|||
! scope="col" | [[Windows Command Prompt]]<!--Not [[COMMAND.COM]]! Far too many of these don't apply to COMMAND.COM.--> |
|||
! scope="col" | [[Unix shell]] |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | {{mono|Get-ChildItem}} |
|||
| {{mono|gci, dir, ls}}{{efn|<code>ls</code> and <code>man</code> aliases are absent in the Linux version of PowerShell Core.|name = absent-linux-aliases}} |
|||
| {{mono|[[dir (command)|dir]]}} |
|||
| {{mono|[[ls]]}} |
|||
|Lists all files and folders in the current or given folder |
|||
|- |
|||
! scope="row" | {{mono|Test-Connection{{efn|1=While the external [[Ping (networking utility)|ping]] command remains available to PowerShell, Test-Connection's output is a structured [[object (programming)|object]] that can be programmatically inspected.<ref>{{cite web|title=Test-Connection|url=https://technet.microsoft.com/en-us/library/hh849808.aspx|website=PowerShell documentations|publisher=[[Microsoft]]|date=August 9, 2015}}</ref>}}}} |
|||
| {{mono|[[Ping (networking utility)|ping]]}} |
|||
| {{mono|[[Ping (networking utility)|ping]]}} |
|||
| {{mono|[[Ping (networking utility)|ping]]}} |
|||
|Sends [[ICMP Echo Request|ICMP echo requests]] to the specified machine from the current machine, or instructs another machine to do so |
|||
|- |
|||
! scope="row" | {{mono|Get-Content}} |
|||
| {{mono|gc}}, {{mono|type}}, {{mono|cat}} |
|||
| {{mono|[[TYPE (DOS command)|type]]}} |
|||
| {{mono|[[cat (Unix)|cat]]}} |
|||
|Gets the content of a file |
|||
|- |
|||
! scope="row" | {{mono|Get-Command}} |
|||
| {{mono|gcm}} |
|||
| {{mono|[[help (command)|help]]}}, {{mono|[[Where (command)|where]]}} |
|||
| {{mono|[[type (Unix)|type]]}}, {{mono|[[which (command)|which]]}}, {{mono|[[compgen (Unix)|compgen]]}} |
|||
|Lists available commands and gets command path |
|||
|- |
|||
! scope="row" | {{mono|Get-Help}} |
|||
| {{mono|help}}, {{mono|man}}{{efn|name = absent-linux-aliases}} |
|||
| {{mono|[[help (command)|help]]}} |
|||
| {{mono|[[apropos (Unix)|apropos]]}}, {{mono|[[Manpage|man]]}} |
|||
|Prints a command's documentation on the console |
|||
|- |
|||
! scope="row" | {{mono|Clear-Host}} |
|||
| {{mono|cls}}, {{mono|clear}} |
|||
| {{mono|[[cls (computing)|cls]]}} |
|||
| {{mono|[[clear (Unix)|clear]]}} |
|||
|Clears the screen{{efn|Clear-Host is implemented as a predefined PowerShell function.}} |
|||
|- |
|||
! scope="row" | {{mono|Copy-Item}} |
|||
| {{mono|cpi}}, {{mono|copy}}, {{mono|cp}} |
|||
| {{mono|[[copy (command)|copy]]}}, {{mono|[[xcopy]]}}, {{mono|[[robocopy]]}} |
|||
| {{mono|[[cp (Unix)|cp]]}} |
|||
|Copies files and folders to another location |
|||
|- |
|||
! scope="row" | {{mono|Move-Item}} |
|||
| {{mono|mi}}, {{mono|move}}, {{mono|mv}} |
|||
| {{mono|[[move (command)|move]]}} |
|||
| {{mono|[[mv (Unix)|mv]]}} |
|||
|Moves files and folders to a new location |
|||
|- |
|||
! scope="row" | {{mono|Remove-Item}} |
|||
| {{mono|ri}}, {{mono|del}}, {{mono|erase}}, {{mono|rmdir}}, {{mono|rd}}, {{mono|rm}} |
|||
| {{mono|[[del (command)|del]]}}, {{mono|[[del (command)|erase]]}}, {{mono|[[rmdir]]}}, {{mono|[[rmdir|rd]]}} |
|||
| {{mono|[[Rm (Unix)|rm]]}}, {{mono|rmdir}} |
|||
|Deletes files or folders |
|||
|- |
|||
! scope="row" | {{mono|Rename-Item}} |
|||
| {{mono|rni}}, {{mono|ren}} |
|||
| {{mono|[[ren (command)|ren]]}}, {{mono|[[ren (command)|rename]]}} |
|||
| {{mono|[[mv (Unix)|mv]]}} |
|||
|Renames a single file, folder, hard link or symbolic link |
|||
|- |
|||
! scope="row" | {{mono|Get-Location}} |
|||
| {{mono|gl}}, {{mono|pwd}} |
|||
| {{mono|[[cd (command)|cd]]}} |
|||
| {{mono|[[pwd]]}} |
|||
|Displays the working path (current folder) |
|||
|- |
|||
! scope="row" | {{mono|Pop-Location}} |
|||
| {{mono|popd}} |
|||
| {{mono|[[pushd and popd|popd]]}} |
|||
| {{mono|popd}} |
|||
|Changes the working path to the location most recently pushed onto the stack |
|||
|- |
|||
! scope="row" | {{mono|Push-Location}} |
|||
| {{mono|pushd}} |
|||
| {{mono|[[pushd and popd|pushd]]}} |
|||
| {{mono|pushd}} |
|||
|Stores the working path onto the stack |
|||
|- |
|||
! scope="row" | {{mono|Set-Location}} |
|||
| {{mono|sl}}, {{mono|cd}}, {{mono|chdir}} |
|||
| {{mono|[[cd (command)|cd]]}}, {{mono|[[cd (command)|chdir]]}} |
|||
| {{mono|cd}} |
|||
|Changes the working path |
|||
|- |
|||
! scope="row" | {{mono|Tee-Object}} |
|||
| {{mono|tee}} |
|||
| {{n/a}} |
|||
| {{mono|[[tee (command)|tee]]}} |
|||
|Pipes input to a file or variable, passing the input along the pipeline |
|||
|- |
|||
! scope="row" | {{mono|Write-Output}} |
|||
| {{mono|echo}}, {{mono|write}} |
|||
| {{mono|[[echo (command)|echo]]}} |
|||
| {{mono|echo}} |
|||
|Prints strings or other objects to the [[standard output]] |
|||
|- |
|||
! scope="row" | {{mono|Get-Process}} |
|||
| {{mono|gps}}, {{mono|ps}} |
|||
| {{mono|tlist}},{{efn|name="Available tlist kill"|1=Available in [[Windows NT 4]], [[Resource Kit#Windows Resource Kits|Windows 98 Resource Kit]], Windows 2000 Support Tools}} {{mono|[[tasklist]]}}{{efn|name="Available tasklist taskkill"|1=Introduced in Windows XP Professional Edition}} |
|||
| {{mono|[[Ps (Unix)|ps]]}} |
|||
|Lists all running processes |
|||
|- |
|||
! scope="row" | {{mono|Stop-Process}} |
|||
| {{mono|spps}}, {{mono|kill}} |
|||
| {{mono|[[kill (command)|kill]]}},{{efn|name="Available tlist kill"}} {{mono|[[taskkill]]}}{{efn|name="Available tasklist taskkill"}} |
|||
| {{mono|kill}}{{efn|name="UNIX kill misnomer"|1=Also used in UNIX to send a process any [[signal (computing)|signal]], the "Terminate" signal is merely the default}} |
|||
|Stops a running process |
|||
|- |
|||
! scope="row" | {{mono|Select-String}} |
|||
| {{mono|sls}} |
|||
| {{mono|[[find (Windows)|find]]}}, {{mono|[[findstr (computing)|findstr]]}} |
|||
| {{mono|[[grep]]}} |
|||
|Prints lines matching a pattern |
|||
|- |
|||
! scope="row" | {{mono|Set-Variable}} |
|||
| {{mono|sv}}, {{mono|set}} |
|||
| {{mono|[[Environment variable#DOS|set]]}} |
|||
| {{mono|env}}, {{mono|export}}, {{mono|set}}, {{mono|setenv}} |
|||
|Creates or alters the contents of an [[environment variable]] |
|||
|- |
|||
! scope="row" | {{mono|Invoke-WebRequest}} |
|||
| {{mono|iwr}}, <s>{{mono|curl}}, {{mono|wget}}</s>{{efn|<code>curl</code> and <code>wget</code> aliases are absent from PowerShell Core, so as to not interfere with invoking similarly named native commands.}} |
|||
| {{mono|[[cURL|curl]]}}<ref>{{Cite web |url=https://techcommunity.microsoft.com/t5/Containers/Tar-and-Curl-Come-to-Windows/ba-p/382409 |title=Tar and Curl Come to Windows! - Microsoft Tech Community - 382409 |date=March 22, 2019 |access-date=May 17, 2020 |archive-date=September 11, 2020 |archive-url=https://web.archive.org/web/20200911181923/https://techcommunity.microsoft.com/t5/containers/tar-and-curl-come-to-windows/ba-p/382409 |url-status=live }}</ref> |
|||
| {{mono|[[wget]]}}, {{mono|curl}} |
|||
|Gets contents from a web page on the Internet |
|||
|} |
|||
'''Notes''' |
|||
{{Notelist}} |
|||
== Filename extensions <span class="anchor" id="Extensions"></span> == |
|||
{| class="wikitable" |
|||
! Extension |
|||
! Description |
|||
|- |
|||
| .ps1 || Script file<ref>{{cite web |last1=Wheeler |first1=Sean |title=About Scripts |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.1 |website=Microsoft Docs |publisher=Microsoft |date=June 2, 2020}}</ref> |
|||
|- |
|||
| .psd1 || Module's manifest file; usually comes with a script module or binary module<ref>{{cite web |last1=Wheeler |first1=Sean |last2=Smatlak |first2=David |last3=Wilson |first3=Chase |title=How to write a PowerShell module manifest |url=https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7 |website=Docs |publisher=Microsoft |date=October 16, 2019}}</ref> |
|||
|- |
|||
| .psm1 || Script module file<ref>{{cite web |last1=Wheeler |first1=Sean |last2=Smatlak |first2=David |title=How to Write a PowerShell Script Module |url=https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-script-module?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft |date=November 22, 2019}}</ref> |
|||
|- |
|||
| .dll || [[Dynamic-link library|DLL]]-compliant{{efn|name=DLL-f}} binary module file<ref>{{cite web |last1=Wheeler |first1=Sean |title=How to Write a PowerShell Binary Module |url=https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-binary-module?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft |date=November 13, 2016}}</ref> |
|||
|- |
|||
| .ps1xml || Format and type definitions file<ref name=about_Format.ps1xml /><ref>{{cite web |last1=Wheeler |first1=Sean |last2=Jofre |first2=Juan Pablo |last3=Vorobev |first3=Sergei |last4=Nikolaev |first4=Kirill |last5=Coulter |first5=David |title=About Types.ps1xml |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft |date=June 2, 2020}}</ref> |
|||
|- |
|||
| .xml || [[XML]]-compliant{{efn|name=XML-f}} serialized data file<ref>{{cite web |last1=Wheeler |first1=Sean |title=Export-Clixml |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/export-clixml?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft}}</ref> |
|||
|- |
|||
| .psc1 || Console file<ref>{{cite web |last1=Wheeler |first1=Sean |last2=Jofre |first2=Juan Pablo |last3=Vorobev |first3=Sergei |last4=Nikolaev |first4=Kirill |last5=Coulter |first5=David |title=Export-Console |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/export-console?view=powershell-5.1 |website=Microsoft Docs |publisher=Microsoft}}</ref> |
|||
|- |
|||
| .pssc || Session configuration file<ref>{{cite web |last1=Wheeler |first1=Sean |title=About Session Configuration Files |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_session_configuration_files?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft |date=June 2, 2020}}</ref> |
|||
|- |
|||
| .psrc || Role Capability file<ref>{{cite web |last1=Wheeler |first1=Sean |title=New-PSRoleCapabilityFile |url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-psrolecapabilityfile?view=powershell-7 |website=Microsoft Docs |publisher=Microsoft |date=June 2, 2020}}</ref> |
|||
|} |
|||
{{Notelist|notes= |
|||
{{efn|name=DLL-f|[[Dynamic-link library]] (DLL) is not a PowerShell-only format. It is a generic format for storing compiled .NET [[Assembly language|assembly]]'s code.}} |
|||
{{efn|name=XML-f|[[XML]] is not a PowerShell-only format. It is a popular information interchange format.}} |
|||
}} |
|||
==Application support== |
== Application support == |
||
{| class="wikitable sortable" |
|||
===SnapIns and hosts=== |
|||
{| class="wikitable" style="width:100%; text-align: center;"; class="wikitable sortable" |
|||
|- |
|- |
||
! |
! Application |
||
! |
! Version |
||
! |
! data-sort-type="number" | Cmdlets |
||
! |
! Provider |
||
! |
! Management GUI |
||
|- |
|- |
||
|[[Microsoft Exchange Server|Exchange Server]] |
|[[Microsoft Exchange Server|Exchange Server]] |
||
|2007 |
|2007 |
||
|{{ |
|{{Yes|402}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[Microsoft Windows|Windows Server]] |
|[[Microsoft Windows|Windows Server]] |
||
|[[Windows Server 2008|2008]] |
|[[Windows Server 2008|2008]] |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[Microsoft SQL Server]] |
|[[Microsoft SQL Server]] |
||
|2008 |
|2008 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|- |
|||
|[[SharePoint|Microsoft SharePoint]] |
|||
|2010 |
|||
|{{Yes}} |
|||
|{{Yes}} |
|||
|{{No}} |
|||
|- |
|||
|[[System Center Configuration Manager]] |
|||
|2012 R2 |
|||
|{{Yes|400+}} |
|||
|{{Yes}} |
|||
|{{No}} |
|||
|- |
|- |
||
|[[System Center Operations Manager]] |
|[[System Center Operations Manager]] |
||
|2007 |
|2007 |
||
|{{ |
|{{Yes|74}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[System Center Virtual Machine Manager]] |
|[[System Center Virtual Machine Manager]] |
||
|2007 |
|2007 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[System Center Data Protection Manager]] |
|[[System Center Data Protection Manager]] |
||
|2007 |
|2007 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[Windows Compute Cluster Server]] |
|[[Windows Compute Cluster Server]] |
||
|2007 |
|2007 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|Microsoft Transporter Suite for [[IBM Lotus Domino|Lotus Domino]]<ref>{{cite web | url = http://www.microsoft.com/downloads/details.aspx?familyid=35fc4205-792b-4306-8e4b-0de9cce72172&displaylang=en | title = Microsoft Transporter Suite for Lotus Domino | |
|Microsoft Transporter Suite for [[IBM Lotus Domino|Lotus Domino]]<ref>{{cite web | url = http://www.microsoft.com/downloads/details.aspx?familyid=35fc4205-792b-4306-8e4b-0de9cce72172&displaylang=en | title = Microsoft Transporter Suite for Lotus Domino | website = [[Microsoft]] | access-date = March 7, 2008}}</ref> |
||
|08.02.0012 |
|08.02.0012 |
||
|{{ |
|{{Yes|47}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|Microsoft PowerTools for [[Office Open XML|Open XML]]<ref>{{cite web | url = http://www.codeplex.com/PowerTools | title = PowerTools for Open XML | |
|Microsoft PowerTools for [[Office Open XML|Open XML]]<ref>{{cite web | url = http://www.codeplex.com/PowerTools | title = PowerTools for Open XML | access-date = June 20, 2008}}</ref> |
||
|1.0 |
|1.0 |
||
|{{ |
|{{Yes|33}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[IBM WebSphere MQ]]<ref>{{cite web | url = http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg24017698 | title = MO74: WebSphere MQ |
|[[IBM WebSphere MQ]]<ref>{{cite web | url = http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg24017698 | title = MO74: WebSphere MQ – Windows PowerShell Library | access-date = December 5, 2007}}</ref> |
||
|6.0.2.2 |
|6.0.2.2 |
||
|{{ |
|{{Yes|44}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[ |
|[[Windows 10 IoT Core|IoT Core]] Add-ons<ref>{{cite web | url = https://docs.microsoft.com/en-us/windows-hardware/manufacture/iot/iot-core-adk-addons-command-line-options | title = IoT Core Add-ons command-line options | date = October 15, 2018 | access-date = June 13, 2020}}</ref> |
||
| |
| |
||
|{{ |
|{{Yes|74}} |
||
|{{ |
|{{Unknown}} |
||
|{{ |
|{{Unknown}} |
||
|- |
|- |
||
| |
|[[Quest Software|Quest Management Shell for Active Directory]]<ref>{{cite web | url = http://www.quest.com/powershell/activeroles-server.aspx | title = PowerShell Commands for Active Directory by Quest Software | access-date = July 2, 2008}}</ref> |
||
|1.7 |
|||
|{{Yes|95}} |
|||
|{{No}} |
|||
|{{No}} |
|||
|- |
|||
|Special Operations Software Specops Command<ref>{{cite web | url = http://www.specopssoft.com/powershell/ | title = PowerShell Remoting through Group Policy | access-date = December 7, 2007}}</ref> |
|||
|1.0 |
|1.0 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[VMware |
|[[VMware vSphere]] PowerCLI<ref>{{cite web | url = https://www.vmware.com/go/PowerCLI | archive-url = https://archive.today/20141230022901/https://www.vmware.com/go/PowerCLI | url-status = dead | archive-date = December 30, 2014 | title = VMware vSphere PowerCLI | access-date = September 9, 2014 }}</ref> |
||
| |
|6.5 R1 |
||
|{{ |
|{{Yes|500+}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[Internet Information Services]]<ref>{{cite web | url = |
|[[Internet Information Services]]<ref>{{cite web | url = https://blogs.msdn.com/powershell/archive/2008/07/03/iis7-powershell-provider-tech-preview-2.aspx | work = Windows PowerShell blog |title = IIS7 PowerShell Provider Tech Preview 2 | access-date = July 3, 2008 |archive-url = https://web.archive.org/web/20100204104602/https://blogs.msdn.com/powershell/archive/2008/07/03/iis7-powershell-provider-tech-preview-2.aspx |archive-date = 2010-02-04}}</ref> |
||
|7.0 |
|7.0 |
||
|{{ |
|{{Yes|54}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|- |
|- |
||
|[[Windows 7]] Troubleshooting Center<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2009/06/14/kudos-to-the-win7-diagnostics-team.aspx | title = Kudos to the Win7 Diagnostics Team | |
|[[Windows 7]] Troubleshooting Center<ref>{{cite web | url = http://blogs.msdn.com/powershell/archive/2009/06/14/kudos-to-the-win7-diagnostics-team.aspx | title = Kudos to the Win7 Diagnostics Team | access-date = June 15, 2009}}</ref> |
||
|6.1 |
|6.1 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{No}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[Microsoft Deployment Toolkit]]<ref>{{cite web|url=http://blogs.technet.com/b/mniehaus/archive/2009/07/10/mdt-2010-new-feature-16-powershell-support.aspx|title=MDT 2010 New Feature #16: PowerShell support|first=Niehaus |last=Michael|date=July 10, 2009|access-date=October 27, 2014}}</ref> |
|||
|[[Microsoft Deployment Toolkit]] |
|||
|2010 |
|2010 |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
|[[NetApp]] |
|[[NetApp]] PowerShell Toolkit<ref>{{cite web | url = http://blogs.msdn.com/b/powershell/archive/2010/06/16/kudos-to-netapp-for-data-ontap-powershell-toolkit.aspx | title = Kudos to NetApp for Data ONTAP PowerShell ToolKit | access-date = June 15, 2010}}</ref><ref>{{cite web|url=http://community.netapp.com/t5/Microsoft-Cloud-and-Virtualization-Discussions/NetApp-PowerShell-Toolkit-4-2-released/m-p/120539|title=PowerShell Toolkit 4.2 Announcement|date=June 23, 2016|access-date=September 7, 2016}}</ref> |
||
| |
|4.2 |
||
|{{ |
|{{Yes|2000+}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|- |
||
| |
|JAMS Scheduler – Job Access & Management System<ref>{{cite web | url = http://blogs.msdn.com/b/powershell/archive/2007/06/28/heterogeneous-job-scheduling-with-powershell.aspx | title = Heterogeneous Job Scheduling With PowerShell | access-date = September 15, 2010}}</ref> |
||
|5.0 |
|5.0 |
||
|{{ |
|{{Yes|52}} |
||
|{{ |
|{{Yes}} |
||
|{{ |
|{{Yes}} |
||
|- |
|||
|[[UIAutomation]]<ref>{{cite web | url = http://uiautomation.codeplex.com/ | title = UIAutomation PowerShell Extensions | access-date = February 16, 2012 | archive-date = August 17, 2016 | archive-url = https://web.archive.org/web/20160817204820/http://uiautomation.codeplex.com/ | url-status = dead }}</ref> |
|||
|0.8 |
|||
|{{Yes|432}} |
|||
|{{No}} |
|||
|{{No}} |
|||
|- |
|||
|[[Dell]] Equallogic<ref>{{cite web | url = http://en.community.dell.com/techcenter/storage/w/wiki/2688.aspx | title = EqualLogic HIT-ME with PowerShell | access-date = March 9, 2012}}</ref> |
|||
|3.5 |
|||
|{{Yes|55}} |
|||
|{{No}} |
|||
|{{No}} |
|||
|- |
|||
|[[LOGINventory]]<ref>[[:de:LOGINventory]]</ref> |
|||
|5.8 |
|||
|{{Yes}} |
|||
|{{Yes}} |
|||
|{{Yes}} |
|||
|- |
|||
|[[SePSX]]<ref>{{cite web | url = http://sepsx.codeplex.com | archive-url = https://archive.today/20130119175212/http://sepsx.codeplex.com/ | url-status = dead | archive-date = January 19, 2013 | title = Selenium PowerShell eXtensions | access-date = August 20, 2012 }}</ref> |
|||
|0.4.1 |
|||
|{{Yes|39}} |
|||
|{{No}} |
|||
|{{No}} |
|||
|} |
|} |
||
== Alternative implementation == |
|||
===Other=== |
|||
* [[SAPIEN Technologies, Inc.|SAPIEN Technologies]] ActiveX PowerShell (ActiveXPosh) — An [[ActiveX]] [[Component Object Model|COM component]] that allows creating a PowerShell host and use cmdlets and scripts from within COM-compatible scripting languages such as [[VBScript]], [[JScript]] and [[KiXtart]].<ref>http://support.sapien.com/bulletins/activexposh.pdf</ref> |
|||
* Sense/Net 6.0 An open source implementation, currently in beta, of a .NET based Enterprise Content Management System accessible from PowerShell, [http://blog.sensenet.hu/post/2008/10/Geek-paradise---access-your-ECMS-from-PowerShell-command-line.aspx Sense/Net development blog] |
|||
* Quest Software PowerGUI (PowerGUI) — PowerGUI.org - a free community for PowerGUI, a graphical user interface and script editor. |
|||
* PowerWF - [http://powerwf.com/ Visual PowerShell] - Every PowerShell CMDLET becomes a drag-and-drop element for visual scripting. |
|||
==Alternative implementation== |
|||
<!-- Attention: [[Pash (software)]] redirects here. --> |
<!-- Attention: [[Pash (software)]] redirects here. --> |
||
A project named ''Pash'', a [[pun]] on the widely known "[[bash (Unix shell)|bash]]" Unix shell, has been an [[open-source software|open-source]] and [[cross-platform]] reimplementation of PowerShell via the [[Mono (software)|Mono framework]].<ref name="pash">{{cite web|url=http://pash.sourceforge.net/ |title=Pash |work=[[SourceForge]] |publisher=[[Dice Holdings, Inc.]] |access-date=September 27, 2011}}</ref> Pash was created by Igor Moochnick, written in [[C Sharp (programming language)|C#]] and was released under the [[GNU General Public License]]. Pash development stalled in 2008, was restarted on [[GitHub]] in 2012,<ref name="pash project">{{cite web|url=https://github.com/Pash-Project/Pash/ |title=Pash Project|website=[[GitHub]]|access-date=April 10, 2013}}</ref> and finally ceased in 2016 when PowerShell was officially made open-source and cross-platform.<ref>{{Cite web|url=https://github.com/Pash-Project/Pash/issues/429|title=Pash is now obsolete · Issue #429 · Pash-Project/Pash|website=GitHub|language=en|access-date=November 26, 2019}}</ref> |
|||
==See also== |
== See also == |
||
* [[Common Information Model (computing) |
* [[Common Information Model (computing)]] |
||
* [[Comparison of command shells]] |
* [[Comparison of command shells]] |
||
* [[Comparison of programming languages]] |
* [[Comparison of programming languages]] |
||
* [[Web-Based Enterprise Management]] |
* [[Web-Based Enterprise Management]] |
||
* [[Windows Script Host]] |
* [[Windows Script Host]] |
||
* [[Windows Terminal]] |
|||
==References== |
== References == |
||
<!--based on article version in May 2006 where the first reference was added, the date format in citations should be MMDDYYYY (e.g. October 26, 1964) with retrieved-by dates in format YYYY-MM-DD (as in 1964-10-26)--> |
|||
{{reflist|2}} |
|||
{{Reflist|30em|refs= |
|||
<ref name="how">{{cite web | url = https://stackoverflow.com/questions/tagged/powershell | title = powershell | access-date = March 13, 2023 }}</ref> |
|||
}} |
|||
==Further reading== |
== Further reading == |
||
*{{Cite book |last=Finke |first=Douglas |title=Windows PowerShell for Developers |isbn=978-1-4493-2270-0 |year=2012 |publisher=[[O'Reilly Media]] |ref=none}} |
|||
* {{cite book|url=http://academic.cengage.com/cengage/instructor/print.do?product_isbn=9781598633542&disciplineName=Programming|title=Microsoft Windows PowerShell Programming for the Absolute Beginner |first=Jerry Lee Jr|last=Ford|id=ISBN 1-59863-354-6}} |
|||
* |
*{{Cite book |last=Holmes |first=Lee |year=2006 |title=Windows PowerShell Quick Reference |isbn=0-596-52813-2 |publisher=[[O'Reilly Media]] |ref=none}} |
||
*{{Cite book |last=Holmes |first=Lee |year=2007 |title=Windows PowerShell Cookbook |isbn=978-0-596-52849-2 |publisher=[[O'Reilly Media]] |ref=none}} |
|||
* {{cite book|url=http://www.oreilly.com/catalog/9780596528492/index.html|title=Windows PowerShell Cookbook|first=Lee|last=Holmes|id=ISBN 0-596-52849-3|accessdate=2010-09-19}} |
|||
*{{Cite book |last1=Jones |first1=Don |last2=Hicks |first2=Jeffery |title=Windows PowerShell 2.0: TFM |isbn=978-0-9821314-2-8 |year=2010 |edition=3rd |publisher=Sapien Technologies |ref=none}} |
|||
* {{cite book|url=http://www.wrox.com/WileyCDA/WroxTitle/Scripting-SQL-Management-Objects-in-Windows-PowerShell.productCd-0470279354.html|title=Scripting SQL Management Objects in Windows PowerShell|first=Willis|last=Johnson|isbn= 978-0-470-27935-9|accessdate= 2010-09-19}} |
|||
*{{Cite book |last=Jones |first=Don |title=Shell of an Idea: The Untold History of PowerShell|publisher=Self-published|year=2020|isbn=978-1-9536450-3-6 |ref=none}} |
|||
* {{cite book|url=http://www.scriptingoutpost.com/ProductInfo.aspx?productid=BK-TFM-PSH|title=Windows PowerShell: TFM|first=Don|last=Jones|id=ISBN 0-9776597-2-0}}{{dead link|date=September 2010}} |
|||
*{{Cite book |last1=Kopczynski |first1=Tyson |last2=Handley |first2=Pete |first3=Marco |last3=Shaw |title=Windows PowerShell Unleashed |isbn=978-0-672-32988-3 |edition=2nd |year=2009 |publisher=[[Pearson Education]] |ref=none}} |
|||
* {{cite book |url=http://www.informit.com/title/0672329530|title=Windows PowerShell Unleashed|first=Tyson |last=Kopczynski|id=ISBN 0-672-32953-0}} |
|||
* |
*{{Cite book |last1=Kumaravel |first1=Arul |first2=Jon |last2=White |first3=Michael |last3=Naixin Li |first4=Scott |last4=Happell |first5=Guohui |last5=Xie |first6=Krishna C. |last6=Vutukuri |title= Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers |isbn= 978-0-470-17393-0 |year=2008 |publisher=[[Wrox Press]] |ref=none}} |
||
* |
*{{Cite book |last=Oakley |first=Andy |title=Monad (AKA PowerShell) |isbn=0-596-10009-4 |year=2005 |publisher=[[O'Reilly Media]] |ref=none}} |
||
*{{Cite book |last=Watt |first=Andrew |year=2007 |title=Professional Windows PowerShell |isbn=978-0-471-94693-9 |publisher=[[Wrox Press]] |ref=none}} |
|||
* {{cite book|url=http://www.manning.com/payette/|title=Windows PowerShell in Action|first=Bruce|last=Payette|id=ISBN 1-932394-90-7|accessdate=2010-09-19}} |
|||
*{{Cite book |last=Wilson |first=Ed |year=2013|title=Windows PowerShell 3.0 Step by Step |isbn=978-0-7356-6339-8 |publisher=[[Microsoft Press]] |ref=none}} |
|||
* {{cite book|url=http://sapienpress.com/vmware.asp|title=Managing VMware Infrastructure with Windows PowerShell: TFM|first=Hal|last=Rottenberg|id=ISBN 0-9821314-0-2|accessdate=2010-09-19}} |
|||
*{{cite book |last=Wilson |first=Ed |year=2014|title=Windows PowerShell Best Practices |publisher=[[Microsoft Press]] |isbn=978-0-7356-6649-8 |ref=none}} |
|||
* {{cite book|title=Windows PowerShell Unleashed|subtitle=|author=Tyson Kopczynski, Pete Handley, Marco Shaw|url=http://www.informit.com/title/0672329883|id=ISBN 978-0-672-32988-3}} |
|||
* {{cite book|url=http://www.wrox.com/WileyCDA/WroxTitle/productCd-0471946931.html|title=Professional Windows PowerShell|first=Andrew|last=Watt|id=ISBN 0-471-94693-1|accessdate=2010-09-19}} |
|||
* {{cite book|url=http://www.microsoft.com/MSPress/books/10329.aspx|title=Microsoft Windows PowerShell Step By Step|first=Ed|last=Wilson|id=ISBN 0-7356-2395-3}} |
|||
==External links== |
== External links == |
||
{{Wikiversity|PowerShell}} |
|||
*[http://technet.microsoft.com/en-us/library/bb978526.aspx Microsoft's Windows PowerShell webpage] |
|||
* {{Official website}} |
|||
*[http://blogs.msdn.com/powershell/ Windows PowerShell Team Blog] |
|||
* {{GitHub|PowerShell/PowerShell}} |
|||
*[http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads Windows PowerShell Community Forum] |
|||
* [http://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide-en-us.aspx ''Windows PowerShell Survival Guide''] {{Webarchive|url=https://web.archive.org/web/20120915113215/http://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide-en-us.aspx |date=September 15, 2012 }} on [[Microsoft TechNet|TechNet]] Wiki |
|||
{{Windows Components}} |
{{Windows Components}} |
||
{{Windows commands}} |
{{Windows commands}} |
||
{{Common Language Infrastructure}} |
|||
{{DotNET|close}} |
|||
{{Microsoft APIs}} |
{{Microsoft APIs}} |
||
{{Microsoft FOSS}} |
|||
{{DEFAULTSORT:Windows Powershell}} |
|||
[[Category:.NET programming languages]] |
[[Category:.NET programming languages]] |
||
[[Category:Unix shells]] |
|||
[[Category:Windows command shells]] |
|||
[[Category:Dynamically typed programming languages]] |
[[Category:Dynamically typed programming languages]] |
||
[[Category:Configuration management]] |
|||
[[Category:Free and open-source software]] |
|||
[[Category:Interpreters (computing)]] |
[[Category:Interpreters (computing)]] |
||
[[Category: |
[[Category:Microsoft free software]] |
||
[[Category:Microsoft programming languages]] |
|||
[[Category:Object-oriented programming languages]] |
[[Category:Object-oriented programming languages]] |
||
[[Category:Procedural programming languages]] |
[[Category:Procedural programming languages]] |
||
[[Category:Programming languages created in 2006]] |
|||
[[Category:Scripting languages]] |
[[Category:Scripting languages]] |
||
[[Category:Software using the MIT license]] |
|||
[[Category:Text-oriented programming languages]] |
[[Category:Text-oriented programming languages]] |
||
[[Category: |
[[Category:Windows administration]] |
||
[[Category:Formerly proprietary software]] |
|||
[[ar:ويندوز باورشيل]] |
|||
[[ca:Windows PowerShell]] |
|||
[[cs:Windows PowerShell]] |
|||
[[de:Windows PowerShell]] |
|||
[[es:Windows PowerShell]] |
|||
[[fa:ویندوز پاورشل]] |
|||
[[fr:Windows PowerShell]] |
|||
[[ko:윈도 파워셸]] |
|||
[[id:Windows PowerShell]] |
|||
[[it:Windows PowerShell]] |
|||
[[nl:Windows PowerShell]] |
|||
[[ja:Windows PowerShell]] |
|||
[[pl:Windows PowerShell]] |
|||
[[pt:Windows PowerShell]] |
|||
[[ru:Windows PowerShell]] |
|||
[[fi:Windows PowerShell]] |
|||
[[tr:Windows PowerShell]] |
|||
[[uk:Windows PowerShell]] |
|||
[[yi:Windows PowerShell]] |
|||
[[zh:Windows PowerShell]] |
Latest revision as of 14:20, 13 December 2024
Paradigm | Imperative, pipeline, object-oriented, functional and reflective |
---|---|
Designed by | Jeffrey Snover, Bruce Payette, James Truher (et al.) |
Developer | Microsoft |
First appeared | November 14, 2006 |
Stable release | |
Typing discipline | Strong, safe, implicit and dynamic |
Implementation language | C# |
Platform | PowerShell: .NET Windows PowerShell: .NET Framework |
OS |
|
License | MIT License[3] (but the Windows component remains proprietary) |
Filename extensions |
|
Website | microsoft |
Influenced by | |
Python, Ksh, Perl, C#, CL, DCL, SQL, Tcl, Tk,[4] Chef, Puppet |
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-source and cross-platform on August 18, 2016, with the introduction of PowerShell Core.[5] The former is built on the .NET Framework, the latter on .NET (previously .NET Core).
PowerShell is bundled with all currently supported Windows versions, and can also be installed on macOS and Linux.[5] Since Windows 10 build 14971, PowerShell replaced Command Prompt (cmd.exe) and became the default command shell for File Explorer.[6][7]
In PowerShell, administrative tasks are generally performed via cmdlets (pronounced command-lets), which are specialized .NET classes implementing a particular operation. These work by accessing data in different data stores, like the file system or Windows Registry, which are made available to PowerShell via providers. Third-party developers can add cmdlets and providers to PowerShell.[8][9] Cmdlets may be used by scripts, which may in turn be packaged into modules. Cmdlets work in tandem with the .NET API.
PowerShell's support for .NET Remoting, WS-Management, CIM, and SSH enables administrators to perform administrative tasks on both local and remote Windows systems. PowerShell also provides a hosting API with which the PowerShell runtime can be embedded inside other applications. These applications can then use PowerShell functionality to implement certain operations, including those exposed via the graphical interface. This capability has been used by Microsoft Exchange Server 2007 to expose its management functionality as PowerShell cmdlets and providers and implement the graphical management tools as PowerShell hosts which invoke the necessary cmdlets.[8][10] Other Microsoft applications including Microsoft SQL Server 2008 also expose their management interface via PowerShell cmdlets.[11]
PowerShell includes its own extensive, console-based help (similar to man pages in Unix shells) accessible via the Get-Help
cmdlet. Updated local help contents can be retrieved from the Internet via the Update-Help
cmdlet. Alternatively, help from the web can be acquired on a case-by-case basis via the -online
switch to Get-Help
.
Background
[edit]The command-line interpreter (CLI) has been an inseparable part of most Microsoft operating systems. MS-DOS and Xenix relied almost exclusively on the CLI (though MS-DOS 5 also came with a complementary graphical DOS Shell.) The Windows 9x family came bundled with COMMAND.COM, the command-line environment of MS-DOS. The Windows NT and Windows CE families, however, came with a new cmd.exe that bore strong similarities to COMMAND.COM. Both environments support a few basic internal commands and a primitive scripting language (batch files), which can be used to automate various tasks. However, they cannot automate all facets of Windows graphical user interface (GUI) because command-line equivalents of operations are limited and the scripting language is elementary.
Microsoft attempted to address some of these shortcomings by introducing the Windows Script Host in 1998 with Windows 98, and its command-line based host, cscript.exe
. It integrates with the Active Script engine and allows scripts to be written in compatible languages, such as JScript and VBScript, leveraging the APIs exposed by applications via the component object model (COM). Its shortcomings are: its documentation is not very accessible, and it quickly gained a reputation as a system vulnerability vector after several high-profile computer viruses exploited weaknesses in its security provisions. Different versions of Windows provided various special-purpose command-line interpreters (such as netsh and WMIC) with their own command sets but they were not interoperable. Windows Server 2003 further attempted to improve the command-line experience but scripting support was still unsatisfactory.[12]
Kermit
[edit]By the late 1990s, Intel had come to Microsoft asking for help in making Windows, which ran on Intel CPUs, a more appropriate platform to support the development of future Intel CPUs. At the time, Intel CPU development was accomplished on Sun Microsystems computers which ran Solaris (a Unix variant) on RISC-architecture CPUs. The ability to run Intel's many KornShell automation scripts on Windows was identified as a key capability. Internally, Microsoft began an effort to create a Windows port of Korn Shell, which was code-named Kermit.[13] Intel ultimately pivoted to a Linux-based development platform that could run on Intel CPUs, rendering the Kermit project redundant. However, with a fully funded team, Microsoft program manager Jeffrey Snover realized there was an opportunity to create a more general-purpose solution to Microsoft's problem of administrative automation.
Monad
[edit]By 2002, Microsoft had started to develop a new approach to command-line management, including a CLI called Monad (also known as Microsoft Shell or MSH). The ideas behind it were published in August 2002 in a white paper called the "Monad Manifesto" by its chief architect, Jeffrey Snover.[14] In a 2017 interview, Snover explains the genesis of PowerShell, saying that he had been trying to make Unix tools available on Windows, which didn't work due to "core architectural difference[s] between Windows and Linux". Specifically, he noted that Linux considers everything a text file, whereas Windows considers everything an "API that returns structured data". They were fundamentally incompatible, which led him to take a different approach.[15]
Monad was to be a new extensible CLI with a fresh design capable of automating a range of core administrative tasks. Microsoft first demonstrated Monad publicly at the Professional Development Conference in Los Angeles in October 2003. A few months later, they opened up private beta, which eventually led to a public beta. Microsoft published the first Monad public beta release on June 17, 2005, and the Beta 2 on September 11, 2005, and Beta 3 on January 10, 2006.
PowerShell
[edit]On April 25, 2006, not long after the initial Monad announcement, Microsoft announced that Monad had been renamed Windows PowerShell, positioning it as a significant part of its management technology offerings.[16] Release Candidate (RC) 1 of PowerShell was released at the same time. A significant aspect of both the name change and the RC was that this was now a component of Windows, rather than a mere add-on.
Release Candidate 2 of PowerShell version 1 was released on September 26, 2006, with final release to the web on November 14, 2006. PowerShell for earlier versions of Windows was released on January 30, 2007.[17] PowerShell v2.0 development began before PowerShell v1.0 shipped. During the development, Microsoft shipped three community technology previews (CTP). Microsoft made these releases available to the public. The last CTP release of Windows PowerShell v2.0 was made available in December 2008.
PowerShell v2.0 was completed and released to manufacturing in August 2009, as an integral part of Windows 7 and Windows Server 2008 R2. Versions of PowerShell for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008 were released in October 2009 and are available for download for both 32-bit and 64-bit platforms.[18] In an October 2009 issue of TechNet Magazine, Microsoft called proficiency with PowerShell "the single most important skill a Windows administrator will need in the coming years".[19]
Windows 10 shipped with Pester, a script validation suite for PowerShell.[20]
On August 18, 2016, Microsoft announced[21] that they had made PowerShell open-source and cross-platform with support for Windows, macOS, CentOS and Ubuntu.[5] The source code was published on GitHub.[22] The move to open source created a second incarnation of PowerShell called "PowerShell Core", which runs on .NET Core. It is distinct from "Windows PowerShell", which runs on the full .NET Framework.[23] Starting with version 5.1, PowerShell Core is bundled with Windows Server 2016 Nano Server.[24][25]
Design
[edit]A key design tactic for PowerShell was to leverage the large number of APIs that already existed in Windows, Windows Management Instrumentation, .NET Framework, and other software. PowerShell cmdlets "wrap around" existing functionality. The intent with this tactic is to provide an administrator-friendly, more-consistent interface between administrators and a wide range of underlying functionality. With PowerShell, an administrator doesn't need to know .NET, WMI, or low-level API coding, and can instead focus on using the cmdlets exposed by PowerShell. In this regard, PowerShell creates little new functionality, instead focusing on making existing functionality more accessible to a particular audience.[26]
Grammar
[edit]PowerShell's developers based the core grammar of the tool on that of the POSIX 1003.2 KornShell.[27]
However, PowerShell's language was also influenced by PHP, Perl, and many other existing languages.[28]
Named Commands
[edit]Windows PowerShell can execute four kinds of named commands:[29]
- cmdlets (.NET Framework programs designed to interact with PowerShell)
- PowerShell scripts (files suffixed by
.ps1
) - PowerShell functions
- Standalone executable programs
If a command is a standalone executable program, PowerShell launches it in a separate process; if it is a cmdlet, it executes in the PowerShell process. PowerShell provides an interactive command-line interface, where the commands can be entered and their output displayed. The user interface offers customizable tab completion. PowerShell enables the creation of aliases for cmdlets, which PowerShell textually translates into invocations of the original commands. PowerShell supports both named and positional parameters for commands. In executing a cmdlet, the job of binding the argument value to the parameter is done by PowerShell itself, but for external executables, arguments are parsed by the external executable independently of PowerShell interpretation.[30]
Extended Type System
[edit]The PowerShell Extended Type System (ETS) is based on the .NET type system, but with extended semantics (for example, propertySets and third-party extensibility). For example, it enables the creation of different views of objects by exposing only a subset of the data fields, properties, and methods, as well as specifying custom formatting and sorting behavior. These views are mapped to the original object using XML-based configuration files.[31]
Cmdlets
[edit]Cmdlets are specialized commands in the PowerShell environment that implement specific functions. These are the native commands in the PowerShell stack. Cmdlets follow a Verb-Noun naming pattern, such as Get-ChildItem, which makes it self-documenting code.[32] Cmdlets output their results as objects and can also receive objects as input, making them suitable for use as recipients in a pipeline. If a cmdlet outputs multiple objects, each object in the collection is passed down through the entire pipeline before the next object is processed.[32]
Cmdlets are specialized .NET classes, which the PowerShell runtime instantiates and invokes at execution time. Cmdlets derive either from Cmdlet
or from PSCmdlet
, the latter being used when the cmdlet needs to interact with the PowerShell runtime.[32] These base classes specify certain methods – BeginProcessing()
, ProcessRecord()
and EndProcessing()
– which the cmdlet's implementation overrides to provide the functionality. Whenever a cmdlet runs, PowerShell invokes these methods in sequence, with ProcessRecord()
being called if it receives pipeline input.[33] If a collection of objects is piped, the method is invoked for each object in the collection. The class implementing the cmdlet must have one .NET attribute – CmdletAttribute
– which specifies the verb and the noun that make up the name of the cmdlet. Common verbs are provided as an enum.[34][35]
If a cmdlet receives either pipeline input or command-line parameter input, there must be a corresponding property in the class, with a mutator implementation. PowerShell invokes the mutator with the parameter value or pipeline input, which is saved by the mutator implementation in class variables. These values are then referred to by the methods which implement the functionality. Properties that map to command-line parameters are marked by ParameterAttribute
[36] and are set before the call to BeginProcessing()
. Those which map to pipeline input are also flanked by ParameterAttribute
, but with the ValueFromPipeline
attribute parameter set.[37]
The implementation of these cmdlet classes can refer to any .NET API and may be in any .NET language. In addition, PowerShell makes certain APIs available, such as WriteObject()
, which is used to access PowerShell-specific functionality, such as writing resultant objects to the pipeline. Cmdlets can use .NET data access APIs directly or use the PowerShell infrastructure of PowerShell Providers, which make data stores addressable using unique paths. Data stores are exposed using drive letters, and hierarchies within them, addressed as directories. Windows PowerShell ships with providers for the file system, registry, the certificate store, as well as the namespaces for command aliases, variables, and functions.[38] Windows PowerShell also includes various cmdlets for managing various Windows systems, including the file system, or using Windows Management Instrumentation to control Windows components. Other applications can register cmdlets with PowerShell, thus allowing it to manage them, and, if they enclose any datastore (such as a database), they can add specific providers as well.[citation needed]
The number of cmdlets included in the base PowerShell install has generally increased with each version:
Version | Cmdlets | Ref |
---|---|---|
Windows PowerShell 1.0 | 129 |
[39] |
Windows PowerShell 2.0 | 632 |
[40] |
Windows PowerShell 3.0 | about 1,000 |
[41] |
Windows PowerShell 4.0 | ? | |
Windows PowerShell 5.0 | about 1,300 |
[42] |
Windows PowerShell 5.1 | 1,586 |
[citation needed] |
PowerShell Core 6.0 | ? | |
PowerShell Core 6.1 | ? | |
PowerShell Core 6.2 | ? | |
PowerShell 7.0 | 1,507 |
[citation needed] |
PowerShell 7.1 | ? | |
PowerShell 7.2 | ? | |
PowerShell 7.4 | 1,656 |
Cmdlets can be added into the shell through snap-ins (deprecated in v2) and modules; users are not limited to the cmdlets included in the base PowerShell installation.
Pipeline
[edit]PowerShell implements the concept of a pipeline, which enables piping the output of one cmdlet to another cmdlet as input. As with Unix pipelines, PowerShell pipelines can construct complex commands, using the |
operator to connect stages. However, the PowerShell pipeline differs from Unix pipelines in that stages execute within the PowerShell runtime rather than as a set of processes coordinated by the operating system. Additionally, structured .NET objects, rather than byte streams, are passed from one stage to the next. Using objects and executing stages within the PowerShell runtime eliminates the need to serialize data structures, or to extract them by explicitly parsing text output.[43] An object can also encapsulate certain functions that work on the contained data, which become available to the recipient command for use.[44][45] For the last cmdlet in a pipeline, PowerShell automatically pipes its output object to the Out-Default
cmdlet, which transforms the objects into a stream of format objects and then renders those to the screen.[46][47]
Because all PowerShell objects are .NET objects, they share a .ToString()
method, which retrieves the text representation of the data in an object. In addition, PowerShell allows formatting definitions to be specified, so the text representation of objects can be customized by choosing which data elements to display, and in what manner. However, in order to maintain backward compatibility, if an external executable is used in a pipeline, it receives a text stream representing the object, instead of directly integrating with the PowerShell type system.[48][49][50]
Scripting
[edit]Windows PowerShell includes a dynamically typed scripting language which can implement complex operations using cmdlets imperatively. The scripting language supports variables, functions, branching (if-then-else
), loops (while
, do
, for
, and foreach
), structured error/exception handling and closures/lambda expressions,[51] as well as integration with .NET. Variables in PowerShell scripts are prefixed with $
. Variables can be assigned any value, including the output of cmdlets. Strings can be enclosed either in single quotes or in double quotes: when using double quotes, variables will be expanded even if they are inside the quotation marks. Enclosing the path to a file in braces preceded by a dollar sign (as in ${C:\foo.txt}
) creates a reference to the contents of the file. If it is used as an L-value, anything assigned to it will be written to the file. When used as an R-value, the contents of the file will be read. If an object is assigned, it is serialized before being stored.[citation needed]
Object members can be accessed using .
notation, as in C# syntax. PowerShell provides special variables, such as $args
, which is an array of all the command-line arguments passed to a function from the command line, and $_
, which refers to the current object in the pipeline.[52] PowerShell also provides arrays and associative arrays. The PowerShell scripting language also evaluates arithmetic expressions entered on the command line immediately, and it parses common abbreviations, such as GB, MB, and KB.[53][54]
Using the function
keyword, PowerShell provides for the creation of functions. A simple function has the following general look:[55]
function name ([Type]$Param1, [Type]$Param2) {
# Instructions
}
However, PowerShell allows for advanced functions that support named parameters, positional parameters, switch parameters and dynamic parameters.[55]
function Verb-Noun {
param (
# Definition of static parameters
)
dynamicparam {
# Definition of dynamic parameters
}
begin {
# Set of instruction to run at the start of the pipeline
}
process {
# Main instruction sets, ran for each item in the pipeline
}
end {
# Set of instruction to run at the end of the pipeline
}
}
The defined function is invoked in either of the following forms:[55]
name value1 value2
Verb-Noun -Param1 value1 -Param2 value2
PowerShell allows any static .NET methods to be called by providing their namespaces enclosed in brackets ([]
), and then using a pair of colons (::
) to indicate the static method.[56] For example:
[Console]::WriteLine("PowerShell")
There are dozens of ways to create objects in PowerShell. Once created, one can access the properties and instance methods of an object using the .
notation.[56]
PowerShell accepts strings, both raw and escaped. A string enclosed between single quotation marks is a raw string while a string enclosed between double quotation marks is an escaped string. PowerShell treats straight and curly quotes as equivalent.[57]
The following list of special characters is supported by PowerShell:[58]
Sequence | Meaning |
---|---|
`0 | Null |
`a | Alert |
`b | Backspace |
`e | Escape (since PowerShell 6) |
`f | Form feed |
`n | Newline |
`r | Carriage return |
`t | Horizontal tab |
`u{x} | Unicode escape sequence (since PowerShell 6) |
`v | Vertical tab |
--% | Treat any character from this point forward literally |
For error handling, PowerShell provides a .NET-based exception-handling mechanism. In case of errors, objects containing information about the error (Exception
object) are thrown, which are caught using the try ... catch
construct (although a trap
construct is supported as well). PowerShell can be configured to silently resume execution, without actually throwing the exception; this can be done either on a single command, a single session or perpetually.[59]
Scripts written using PowerShell can be made to persist across sessions in either a .ps1
file or a .psm1
file (the latter is used to implement a module). Later, either the entire script or individual functions in the script can be used. Scripts and functions operate analogously with cmdlets, in that they can be used as commands in pipelines, and parameters can be bound to them. Pipeline objects can be passed between functions, scripts, and cmdlets seamlessly. To prevent unintentional running of scripts, script execution is disabled by default and must be enabled explicitly.[60] Enabling of scripts can be performed either at system, user or session level. PowerShell scripts can be signed to verify their integrity, and are subject to Code Access Security.[61]
The PowerShell scripting language supports binary prefix notation similar to the scientific notation supported by many programming languages in the C-family.[62]
Hosting
[edit]One can also use PowerShell embedded in a management application, which uses the PowerShell runtime to implement the management functionality. For this, PowerShell provides a managed hosting API. Via the APIs, the application can instantiate a runspace (one instantiation of the PowerShell runtime), which runs in the application's process and is exposed as a Runspace
object.[8] The state of the runspace is encased in a SessionState
object. When the runspace is created, the Windows PowerShell runtime initializes the instantiation, including initializing the providers and enumerating the cmdlets, and updates the SessionState
object accordingly. The Runspace then must be opened for either synchronous processing or asynchronous processing. After that it can be used to execute commands.[citation needed]
To execute a command, a pipeline (represented by a Pipeline
object) must be created and associated with the runspace. The pipeline object is then populated with the cmdlets that make up the pipeline. For sequential operations (as in a PowerShell script), a Pipeline object is created for each statement and nested inside another Pipeline object.[8] When a pipeline is created, Windows PowerShell invokes the pipeline processor, which resolves the cmdlets into their respective assemblies (the command processor) and adds a reference to them to the pipeline, and associates them with InputPipe
, OutputPipe
and ErrorOutputPipe
objects, to represent the connection with the pipeline. The types are verified and parameters bound using reflection.[8] Once the pipeline is set up, the host calls the Invoke()
method to run the commands, or its asynchronous equivalent, InvokeAsync()
. If the pipeline has the Write-Host
cmdlet at the end of the pipeline, it writes the result onto the console screen. If not, the results are handed over to the host, which might either apply further processing or display the output itself.[citation needed]
Microsoft Exchange Server 2007 uses the hosting APIs to provide its management GUI. Each operation exposed in the GUI is mapped to a sequence of PowerShell commands (or pipelines). The host creates the pipeline and executes them. In fact, the interactive PowerShell console itself is a PowerShell host, which interprets the scripts entered at command line and creates the necessary Pipeline
objects and invokes them.[citation needed]
Desired State Configuration
[edit]DSC allows for declaratively specifying how a software environment should be configured.[63]
Upon running a configuration, DSC will ensure that the system gets the state described in the configuration. DSC configurations are idempotent. The Local Configuration Manager (LCM) periodically polls the system using the control flow described by resources (imperative pieces of DSC) to make sure that the state of a configuration is maintained.
Versions
[edit]Initially using the code name "Monad", PowerShell was first shown publicly at the Professional Developers Conference in October 2003 in Los Angeles. All major releases are still supported, and each major release has featured backwards compatibility with preceding versions.
Windows PowerShell 1.0
[edit]PowerShell 1.0 was released in November 2006 for Windows XP SP2, Windows Server 2003 SP1 and Windows Vista.[64] It is an optional component of Windows Server 2008.
Windows PowerShell 2.0
[edit]PowerShell 2.0 is integrated with Windows 7 and Windows Server 2008 R2[65] and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, and Windows Vista with Service Pack 1.[66][67]
PowerShell v2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.[68][69]
New features of PowerShell 2.0 include:[70][71][72]
- PowerShell remoting: Using WS-Management, PowerShell 2.0 allows scripts and cmdlets to be invoked on a remote machine or a large set of remote machines.
- Background jobs: Also called a PSJob, it allows a command sequence (script) or pipeline to be invoked asynchronously. Jobs can be run on the local machine or on multiple remote machines. An interactive cmdlet in a PSJob blocks the execution of the job until user input is provided.
- Transactions: Enable cmdlet and developers can perform transactional operations. PowerShell 2.0 includes transaction cmdlets for starting, committing, and rolling back a PSTransaction as well as features to manage and direct the transaction to the participating cmdlet and provider operations. The PowerShell Registry provider supports transactions.
- Advanced functions: These are cmdlets written using the PowerShell scripting language. Initially called "script cmdlets", this feature was later renamed "advanced functions".[73]
- SteppablePipelines: This allows the user to control when the
BeginProcessing()
,ProcessRecord()
andEndProcessing()
functions of a cmdlet are called. - Modules: This allows script developers and administrators to organize and partition PowerShell scripts in self-contained, reusable units. Code from a module executes in its own self-contained context and does not affect the state outside the module. Modules can define a restricted runspace environment by using a script. They have a persistent state as well as public and private members.
- Data language: A domain-specific subset of the PowerShell scripting language that allows data definitions to be decoupled from the scripts and allows localized string resources to be imported into the script at runtime (Script Internationalization).
- Script debugging: It allows breakpoints to be set in a PowerShell script or function. Breakpoints can be set on lines, line & columns, commands and read or write access of variables. It includes a set of cmdlets to control the breakpoints via script.
- Eventing: This feature allows listening, forwarding, and acting on management and system events. Eventing allows PowerShell hosts to be notified about state changes to their managed entities. It also enables PowerShell scripts to subscribe to ObjectEvents, PSEvents, and WmiEvents and process them synchronously and asynchronously.
- Windows PowerShell Integrated Scripting Environment (ISE): PowerShell 2.0 includes a GUI-based PowerShell host that provides integrated debugger, syntax highlighting, tab completion and up to 8 PowerShell Unicode-enabled consoles (Runspaces) in a tabbed UI, as well as the ability to run only the selected parts in a script.
- Network file transfer: Native support for prioritized, throttled, and asynchronous transfer of files between machines using the Background Intelligent Transfer Service (BITS).[74]
- New cmdlets: Including
Out-GridView
, which displays tabular data in the WPF GridView object, on systems that allow it, and if ISE is installed and enabled. - New operators:
-Split
,-Join
, and Splatting (@
) operators. - Exception handling with Try-Catch-Finally: Unlike other .NET languages, this allows multiple exception types for a single catch block.
- Nestable Here-Strings: PowerShell Here-Strings have been improved and can now nest.[75]
- Block comments: PowerShell 2.0 supports block comments using
<#
and#>
as delimiters.[76] - New APIs: The new APIs range from handing more control over the PowerShell parser and runtime to the host, to creating and managing collection of Runspaces (
RunspacePools
) as well as the ability to create Restricted Runspaces which only allow a configured subset of PowerShell to be invoked. The new APIs also support participation in a transaction managed by PowerShell
Windows PowerShell 3.0
[edit]PowerShell 3.0 is integrated with Windows 8 and with Windows Server 2012. Microsoft has also made PowerShell 3.0 available for Windows 7 with Service Pack 1, for Windows Server 2008 with Service Pack 1, and for Windows Server 2008 R2 with Service Pack 1.[77][78]
PowerShell 3.0 is part of a larger package, Windows Management Framework 3.0 (WMF3), which also contains the WinRM service to support remoting.[78] Microsoft made several Community Technology Preview releases of WMF3. An early community technology preview 2 (CTP 2) version of Windows Management Framework 3.0 was released on December 2, 2011.[79] Windows Management Framework 3.0 was released for general availability in December 2012[80] and is included with Windows 8 and Windows Server 2012 by default.[81]
New features in PowerShell 3.0 include:[78][82]: 33–34
- Scheduled jobs: Jobs can be scheduled to run on a preset time and date using the Windows Task Scheduler infrastructure.
- Session connectivity: Sessions can be disconnected and reconnected. Remote sessions have become more tolerant of temporary network failures.
- Improved code writing: Code completion (IntelliSense) and snippets are added. PowerShell ISE allows users to use dialog boxes to fill in parameters for PowerShell cmdlets.
- Delegation support: Administrative tasks can be delegated to users who do not have permissions for that type of task, without granting them perpetual additional permissions.
- Help update: Help documentations can be updated via Update-Help command.
- Automatic module detection: Modules are loaded implicitly whenever a command from that module is invoked. Code completion works for unloaded modules as well.
- New commands: Dozens of new modules were added, including functionality to manage disks
get-WmiObject win32_logicaldisk
, volumes, firewalls, network connections, and printers, which had previously been performed via WMI.[further explanation needed]
Windows PowerShell 4.0
[edit]PowerShell 4.0 is integrated with Windows 8.1 and with Windows Server 2012 R2. Microsoft has also made PowerShell 4.0 available for Windows 7 SP1, Windows Server 2008 R2 SP1 and Windows Server 2012.[83]
New features in PowerShell 4.0 include:
- Desired State Configuration:[84][85][86] Declarative language extensions and tools that enable the deployment and management of configuration data for systems using the DMTF management standards and WS-Management Protocol
- New default execution policy: On Windows Servers, the default execution policy is now
RemoteSigned
. - Save-Help: Help can now be saved for modules that are installed on remote computers.
- Enhanced debugging: The debugger now supports debugging workflows, remote script execution and preserving debugging sessions across PowerShell session reconnections.
- -PipelineVariable switch: A new ubiquitous parameter to expose the current pipeline object as a variable for programming purposes
- Network diagnostics to manage physical and Hyper-V's virtualized network switches
- Where and ForEach method syntax provides an alternate method of filtering and iterating over objects.
Windows PowerShell 5.0
[edit]Windows Management Framework (WMF) 5.0 RTM which includes PowerShell 5.0 was re-released to web on February 24, 2016, following an initial release with a severe bug.[87]
Key features included:
- The new
class
keyword that creates classes for object-oriented programming - The new
enum
keyword that creates enums OneGet
cmdlets to support the Chocolatey package manager[88]- Extending support for switch management to layer 2 network switches.[89]
- Debugging for PowerShell background jobs and instances of PowerShell hosted in other processes (each of which is called a "runspace")
- Desired State Configuration (DSC) Local Configuration Manager (LCM) version 2.0
- DSC partial configurations
- DSC Local Configuration Manager meta-configurations
- Authoring of DSC resources using PowerShell classes
Windows PowerShell 5.1
[edit]It was released along with the Windows 10 Anniversary Update[90] on August 2, 2016, and in Windows Server 2016.[91] PackageManagement now supports proxies, PSReadLine now has ViMode support, and two new cmdlets were added: Get-TimeZone and Set-TimeZone. The LocalAccounts module allows for adding/removing local user accounts.[92] A preview for PowerShell 5.1 was released for Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2 on July 16, 2016,[93] and was released on January 19, 2017.[94]
PowerShell 5.1 is the first version to come in two editions of "Desktop" and "Core". The "Desktop" edition is the continuation of the traditional Windows PowerShell that runs on the .NET Framework stack. The "Core" edition runs on .NET Core and is bundled with Windows Server 2016 Nano Server. In exchange for smaller footprint, the latter lacks some features such as the cmdlets to manage clipboard or join a computer to a domain, WMI version 1 cmdlets, Event Log cmdlets and profiles.[25] This was the final version of PowerShell made exclusively for Windows. Windows PowerShell 5.1 remains pre-installed on Windows 10, Windows 11 and Windows Server 2022, while the .NET PowerShell needs to be installed separately and can run side-by-side with Windows PowerShell.[95][96]
PowerShell Core 6
[edit]PowerShell Core 6.0 was first announced on August 18, 2016, when Microsoft unveiled PowerShell Core and its decision to make the product cross-platform, independent of Windows, free and open source.[5] It achieved general availability on January 10, 2018, for Windows, macOS and Linux.[97] It has its own support lifecycle and adheres to the Microsoft lifecycle policy that is introduced with Windows 10: Only the latest version of PowerShell Core is supported. Microsoft expects to release one minor version for PowerShell Core 6.0 every six months.[98]
The most significant change in this version of PowerShell is the expansion to the other platforms. For Windows administrators, this version of PowerShell did not include any major new features. In an interview with the community on January 11, 2018, the PowerShell team was asked to list the top 10 most exciting things that would happen for a Windows IT professional who would migrate from Windows PowerShell 5.1 to PowerShell Core 6.0; in response, Angel Calvo of Microsoft could only name two: cross-platform and open-source.[99] PowerShell 6 changed to UTF-8 as default encoding, with some exceptions.[100] (PowerShell 7.4 changes more to UTF-8)[101]
6.1
[edit]According to Microsoft, one of the new features of PowerShell 6.1 is "Compatibility with 1900+ existing cmdlets in Windows 10 and Windows Server 2019."[102] Still, no details of these cmdlets can be found in the full version of the change log.[103] Microsoft later professes that this number was insufficient as PowerShell Core failed to replace Windows PowerShell 5.1 and gain traction on Windows.[104] It was, however, popular on Linux.[104]
6.2
[edit]PowerShell Core 6.2 is focused primarily on performance improvements, bug fixes, and smaller cmdlet and language enhancements that improved developer productivity.[105]
PowerShell 7
[edit]PowerShell 7 is the replacement for PowerShell Core 6.x products as well as Windows PowerShell 5.1, which is the last supported Windows PowerShell version.[106][104] The focus in development was to make PowerShell 7 a viable replacement for Windows PowerShell 5.1, i.e. to have near parity with Windows PowerShell in terms of compatibility with modules that ship with Windows.[107]
New features in PowerShell 7 include:[108]
- The
-Parallel
switch for theForEach-Object
cmdlet to help handle parallel processing - Near parity with Windows PowerShell in terms of compatibility with built-in Windows modules
- A new error view
- The
Get-Error
cmdlet - Pipeline chaining operators (
&&
and||
) that allow conditional execution of the next cmdlet in the pipeline - The ?: operator for ternary operation
- The
??
operator for null coalescing - The
??=
operator for null coalescing assignment - Cross-platform
Invoke-DscResource
(experimental) - Return of the
Out-GridView
cmdlet - Return of the
-ShowWindow
switch for theGet-Help
PowerShell 7.2
[edit]PowerShell 7.2 is the next long-term support version of PowerShell, after version 7.0. It uses .NET 6.0 and features universal installer packages for Linux. On Windows, updates to PowerShell 7.2 and later come via the Microsoft Update service; this feature has been missing from PowerShell 6.0 through 7.1.[109]
PowerShell 7.3
[edit]This version includes some general Cmdlet updates and fixes, testing for framework dependent package in release pipeline as well as build and packaging improvements.[110]
PowerShell 7.4
[edit]PowerShell 7.4 is based on .NET 8. And with that release webcmdlets default to UTF-8 encoding (changing from ASCII-superset Windows-1252 aka ISO-8859-1, that does not support Unicode).[111][101] Previously UTF-8 was default for other, but not all, things.
Comparison of cmdlets with similar commands
[edit]The following table contains a selection of the cmdlets that ship with PowerShell, noting similar commands in other well-known command-line interpreters. Many of these similar commands come out-of-the-box defined as aliases within PowerShell, making it easy for people familiar with other common shells to start working.
PowerShell (Cmdlet) | PowerShell (Alias) | Windows Command Prompt | Unix shell | Description |
---|---|---|---|---|
Get-ChildItem | gci, dir, ls[a] | dir | ls | Lists all files and folders in the current or given folder |
Test-Connection[b] | ping | ping | ping | Sends ICMP echo requests to the specified machine from the current machine, or instructs another machine to do so |
Get-Content | gc, type, cat | type | cat | Gets the content of a file |
Get-Command | gcm | help, where | type, which, compgen | Lists available commands and gets command path |
Get-Help | help, man[a] | help | apropos, man | Prints a command's documentation on the console |
Clear-Host | cls, clear | cls | clear | Clears the screen[c] |
Copy-Item | cpi, copy, cp | copy, xcopy, robocopy | cp | Copies files and folders to another location |
Move-Item | mi, move, mv | move | mv | Moves files and folders to a new location |
Remove-Item | ri, del, erase, rmdir, rd, rm | del, erase, rmdir, rd | rm, rmdir | Deletes files or folders |
Rename-Item | rni, ren | ren, rename | mv | Renames a single file, folder, hard link or symbolic link |
Get-Location | gl, pwd | cd | pwd | Displays the working path (current folder) |
Pop-Location | popd | popd | popd | Changes the working path to the location most recently pushed onto the stack |
Push-Location | pushd | pushd | pushd | Stores the working path onto the stack |
Set-Location | sl, cd, chdir | cd, chdir | cd | Changes the working path |
Tee-Object | tee | — | tee | Pipes input to a file or variable, passing the input along the pipeline |
Write-Output | echo, write | echo | echo | Prints strings or other objects to the standard output |
Get-Process | gps, ps | tlist,[d] tasklist[e] | ps | Lists all running processes |
Stop-Process | spps, kill | kill,[d] taskkill[e] | kill[f] | Stops a running process |
Select-String | sls | find, findstr | grep | Prints lines matching a pattern |
Set-Variable | sv, set | set | env, export, set, setenv | Creates or alters the contents of an environment variable |
Invoke-WebRequest | iwr, |
curl[113] | wget, curl | Gets contents from a web page on the Internet |
Notes
- ^ a b
ls
andman
aliases are absent in the Linux version of PowerShell Core. - ^ While the external ping command remains available to PowerShell, Test-Connection's output is a structured object that can be programmatically inspected.[112]
- ^ Clear-Host is implemented as a predefined PowerShell function.
- ^ a b Available in Windows NT 4, Windows 98 Resource Kit, Windows 2000 Support Tools
- ^ a b Introduced in Windows XP Professional Edition
- ^ Also used in UNIX to send a process any signal, the "Terminate" signal is merely the default
- ^
curl
andwget
aliases are absent from PowerShell Core, so as to not interfere with invoking similarly named native commands.
Filename extensions
[edit]Extension | Description |
---|---|
.ps1 | Script file[114] |
.psd1 | Module's manifest file; usually comes with a script module or binary module[115] |
.psm1 | Script module file[116] |
.dll | DLL-compliant[a] binary module file[117] |
.ps1xml | Format and type definitions file[50][118] |
.xml | XML-compliant[b] serialized data file[119] |
.psc1 | Console file[120] |
.pssc | Session configuration file[121] |
.psrc | Role Capability file[122] |
- ^ Dynamic-link library (DLL) is not a PowerShell-only format. It is a generic format for storing compiled .NET assembly's code.
- ^ XML is not a PowerShell-only format. It is a popular information interchange format.
Application support
[edit]Application | Version | Cmdlets | Provider | Management GUI |
---|---|---|---|---|
Exchange Server | 2007 | 402 | Yes | Yes |
Windows Server | 2008 | Yes | Yes | No |
Microsoft SQL Server | 2008 | Yes | Yes | No |
Microsoft SharePoint | 2010 | Yes | Yes | No |
System Center Configuration Manager | 2012 R2 | 400+ | Yes | No |
System Center Operations Manager | 2007 | 74 | Yes | No |
System Center Virtual Machine Manager | 2007 | Yes | Yes | Yes |
System Center Data Protection Manager | 2007 | Yes | No | No |
Windows Compute Cluster Server | 2007 | Yes | Yes | No |
Microsoft Transporter Suite for Lotus Domino[123] | 08.02.0012 | 47 | No | No |
Microsoft PowerTools for Open XML[124] | 1.0 | 33 | No | No |
IBM WebSphere MQ[125] | 6.0.2.2 | 44 | No | No |
IoT Core Add-ons[126] | 74 | Unknown | Unknown | |
Quest Management Shell for Active Directory[127] | 1.7 | 95 | No | No |
Special Operations Software Specops Command[128] | 1.0 | Yes | No | Yes |
VMware vSphere PowerCLI[129] | 6.5 R1 | 500+ | Yes | Yes |
Internet Information Services[130] | 7.0 | 54 | Yes | No |
Windows 7 Troubleshooting Center[131] | 6.1 | Yes | No | Yes |
Microsoft Deployment Toolkit[132] | 2010 | Yes | Yes | Yes |
NetApp PowerShell Toolkit[133][134] | 4.2 | 2000+ | Yes | Yes |
JAMS Scheduler – Job Access & Management System[135] | 5.0 | 52 | Yes | Yes |
UIAutomation[136] | 0.8 | 432 | No | No |
Dell Equallogic[137] | 3.5 | 55 | No | No |
LOGINventory[138] | 5.8 | Yes | Yes | Yes |
SePSX[139] | 0.4.1 | 39 | No | No |
Alternative implementation
[edit]A project named Pash, a pun on the widely known "bash" Unix shell, has been an open-source and cross-platform reimplementation of PowerShell via the Mono framework.[140] Pash was created by Igor Moochnick, written in C# and was released under the GNU General Public License. Pash development stalled in 2008, was restarted on GitHub in 2012,[141] and finally ceased in 2016 when PowerShell was officially made open-source and cross-platform.[142]
See also
[edit]- Common Information Model (computing)
- Comparison of command shells
- Comparison of programming languages
- Web-Based Enterprise Management
- Windows Script Host
- Windows Terminal
References
[edit]- ^ "PowerShell". Microsoft Apps. Retrieved October 24, 2024.
- ^ "Release v7.4.6 Release of PowerShell". PowerShell/PowerShell repo. Microsoft. Retrieved October 22, 2024 – via GitHub.com.
- ^ "PowerShell for every system!". June 12, 2017 – via GitHub.com.
- ^ Snover, Jeffrey (May 25, 2008). "PowerShell and WPF: WTF". Windows PowerShell Blog. Microsoft.
- ^ a b c d Bright, Peter (August 18, 2016). "PowerShell is Microsoft's latest open source release, coming to Linux, OS X". Ars Technica. Condé Nast. Archived from the original on April 9, 2020. Retrieved May 12, 2020.
- ^ "Announcing Windows 10 Insider Preview Build 14971 for PC". November 17, 2016.
- ^ "PowerShell is replacing Command Prompt".
- ^ a b c d e "powershell". Retrieved March 13, 2023.
- ^ Truher, Jim (December 2007). "Extend Windows PowerShell With Custom Commands". MSDN Magazine. Microsoft. Archived from the original on October 6, 2008.
- ^ Lowe, Scott (January 4, 2007). "Exchange 2007: Get used to the command line". TechRepublic. CBS Interactive. Archived from the original on November 16, 2018. Retrieved May 12, 2020.
- ^ Snover, Jeffrey (November 13, 2007). "SQL Server Support for PowerShell!". Windows PowerShell Blog (blog posting). Microsoft. Archived from the original on November 15, 2007. Retrieved November 13, 2007.
- ^ Dragan, Richard V. (April 23, 2003). "Windows Server 2003 Delivers Improvements All Around". PCMag.com. Ziff Davis.
A standout feature here is that virtually all admin utilities now work from the command line (and most are available through telnet).
- ^ Jones, Don (2020). Shell of an Idea: The Untold History of PowerShell. Don Gannon-Jones. p. 25. ISBN 978-1-9536450-3-6.
- ^ Jeffrey P. Snover (August 8, 2002). "Monad Manifesto" (PDF). Windows PowerShell Blog. Microsoft. Retrieved April 2, 2021.
- ^ Biggar and Harbaugh (September 14, 2017). "The Man Behind Windows PowerShell". To Be Continuous (Podcast). Heavybit. Retrieved September 14, 2017.
- ^ "Windows PowerShell (Monad) Has Arrived". Windows PowerShell Blog. Microsoft. April 25, 2006.
- ^ Snover, Jeffrey (November 15, 2006). "Windows PowerShell & Windows Vista". Windows PowerShell Blog (blog posting). Microsoft.
- ^ "Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)". Support. Microsoft. September 30, 2013. Archived from the original on October 13, 2013.
- ^ Posey, Brien (October 6, 2009). "10 reasons why you should learn to use PowerShell". TechRepublic. Retrieved April 2, 2021.
- ^ "What is Pester and Why Should I Care?". December 14, 2015.
- ^ Snover, Jeffrey (August 18, 2016). "PowerShell is open sourced and is available on Linux". Microsoft Azure Blog. Microsoft.
- ^ "PowerShell/PowerShell". GitHub. Retrieved August 18, 2016.
- ^ Hansen, Kenneth; Calvo, Angel (August 18, 2016). "PowerShell on Linux and Open Source!". Windows PowerShell Blog. Microsoft.
- ^ Foley, Mary Jo (August 18, 2016). "Microsoft open sources PowerShell; brings it to Linux and Mac OS X". ZDNet. CBS Interactive.
- ^ a b "PowerShell on Nano Server". TechNet. Microsoft. October 20, 2016.
- ^ Jones, Don (2020). Shell of an Idea: The Untold History of PowerShell. Don Gannon-Jones. p. 45. ISBN 978-1-9536450-3-6.
- ^
Payette, Bruce (2008). Windows PowerShell in Action. Manning Pubs Co Series. Manning. p. 27. ISBN 9781932394900. Retrieved July 22, 2016.
The core PowerShell language is based on the POSIX 1003.2 grammar for the Korn shell.
- ^ Jones, Don (2020). Shell of an Idea: The Untold History of PowerShell. Don Gannon-Jones. p. 109. ISBN 978-1-9536450-3-6.
- ^ "about_Command_Precedence". TechNet. Microsoft. May 8, 2014.
- ^ Wheeler, Sean (September 7, 2021). "about Parsing - PowerShell". Microsoft Docs. Retrieved December 5, 2021.
- ^ "Windows PowerShell Extended Type System". Retrieved November 28, 2007.
- ^ a b c "Windows PowerShell Cmdlets". Retrieved November 28, 2007.
- ^ "Creating Your First Cmdlet". Retrieved November 28, 2007.
- ^ "Get-Verb". TechNet. Microsoft. May 8, 2014.
- ^ "Cmdlet Overview". MSDN. Microsoft. May 8, 2014.
- ^ "Adding parameters That Process Command Line Input". Retrieved November 28, 2007.
- ^ "Adding parameters That Process Pipeline Input". Retrieved November 28, 2007.
- ^ "Windows PowerShell Providers". Retrieved October 14, 2010.
- ^ Yoshizawa, Tomoaki; Ramos, Durval (September 29, 2012). "PowerShell 1.0 Cmdlets". TechNet Articles. Microsoft.
- ^ Yoshizawa, Tomoaki (July 10, 2012). "PowerShell 2.0 Cmdlets". TechNet Articles. Microsoft.
- ^ Wilson, Ed (2013). "1: Overview of Windows PowerShell 3.0". Windows Powershell 3.0 Step by Step. Sebastopol, California: Microsoft Press. ISBN 978-0-7356-7000-6. OCLC 829236530.
Windows PowerShell 3.0 comes with about 1,000 cmdlets on Windows 8
- ^ Wilson, Ed (2015). "1: Overview of Windows PowerShell 5.0". Windows PowerShell Step by Step (Third ed.). Redmond, Washington: Microsoft Press. ISBN 978-1-5093-0043-3. OCLC 927112976.
Windows PowerShell 5.0 comes with about 1,300 cmdlets on Windows 10
- ^ "Windows PowerShell Owner's Manual: Piping and the Pipeline in Windows PowerShell". TechNet. Microsoft. Retrieved September 27, 2011.
- ^ Jones, Don (2008). "Windows PowerShell – Rethinking the Pipeline". Microsoft TechNet. Microsoft. Retrieved November 28, 2007.
- ^ "Windows PowerShell Object Concepts". Archived from the original on August 19, 2007. Retrieved November 28, 2007.
- ^ "How PowerShell Formatting and Outputting REALLY works". Retrieved November 28, 2007.
- ^ "More – How does PowerShell formatting really work?". Retrieved November 28, 2007.
- ^ "about_Pipelines". TechNet. Microsoft. May 8, 2014.
- ^ "about_Objects". TechNet. Microsoft. May 8, 2014.
- ^ a b "about_Format.ps1xml". TechNet. Microsoft. May 8, 2014.
- ^ "Anonymous Functions and Code Blocks in PowerShell". Retrieved January 21, 2012.
- ^ "Introduction to Windows PowerShell's Variables". Retrieved November 28, 2007.
- ^ "Byte Conversion". Windows PowerShell Tip of the Week. October 22, 2009. Retrieved November 15, 2013.
- ^ Ravikanth (May 20, 2013). "Converting to size units (KB, MB, GB, TB, and PB) without using PowerShell multipliers". PowerShell Magazine.
- ^ a b c "about_Functions". Microsoft TechNet. Microsoft. October 17, 2013. Retrieved November 15, 2013.
- ^ a b "Lightweight Testing with Windows PowerShell". Retrieved November 28, 2007.
- ^ Angelopoulos, Alex; Karen, Bemowski (December 4, 2007). "PowerShell Got Smart About Smart Quotes". Windows IT Pro. Penton Media. Retrieved November 15, 2013.
- ^ "About Special Characters". Powershell / Scripting. Microsoft. June 8, 2017. Retrieved June 20, 2019.
- ^ "Trap [Exception] { "In PowerShell" }". Retrieved November 28, 2007.
- ^ "Running Windows PowerShell Scripts". Microsoft. Retrieved November 28, 2007.
- ^ "about_Signing". Microsoft TechNet. Microsoft. October 17, 2013. Retrieved November 15, 2013.
- ^ Lee Holmes (September 2006). Windows PowerShell Quick Reference. O'Reilly Media.
- ^ eslesar (May 23, 2023). "Windows PowerShell Desired State Configuration Overview". msdn.microsoft.com.
- ^ Chung, Leonard; Snover, Jeffrey; Kumaravel, Arul (November 14, 2006). "It's a Wrap! Windows PowerShell 1.0 Released!". Windows PowerShell Blog. Microsoft.
- ^ "PowerShell will be installed by default on Windows Server 08 R2 (WS08R2) and Windows 7 (W7)!". Windows PowerShell Blog. Microsoft. October 28, 2008. Retrieved September 27, 2011.
- ^ "Windows Management Framework is here!". October 27, 2009. Retrieved October 30, 2009.
- ^ "Microsoft Support Knowledge Base: Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)". Support.microsoft.com. September 23, 2011. Retrieved September 27, 2011.
- ^ "574 Reasons Why We Are So Proud and Optimistic About W7 and WS08R2". Windows PowerShell Blog. Microsoft. October 29, 2008. Retrieved September 27, 2011.
- ^ Snover, Jeffrey (2008). "PowerShell: Creating Manageable Web Services". Archived from the original on October 13, 2008. Retrieved July 19, 2015.
- ^ "What's New in CTP of PowerShell 2.0". Retrieved November 28, 2007.
- ^ "Windows PowerShell V2 Community Technology Preview 2 (CTP2) – releaseNotes". Microsoft. Archived from the original on May 6, 2008. Retrieved May 5, 2008.
- ^ "Differences between PowerShell 1.0 and PowerShell 2.0". Archived from the original on September 17, 2010. Retrieved June 26, 2010.
- ^ Jones, Don (May 2010). "Windows PowerShell: Writing Cmdlets in Script". TechNet Magazine. Microsoft.
- ^ "GoGrid Snap-in – Managing Cloud Services with PowerShell". Windows PowerShell Blog. Microsoft. October 14, 2008. Retrieved September 27, 2011.
- ^ "Emit-XML". Windows PowerShell Blog. Microsoft. October 17, 2008. Retrieved September 27, 2011.
- ^ "Block Comments in V2". Windows PowerShell Blog. Microsoft. June 14, 2008. Retrieved September 27, 2011.
- ^ Lee, Thomas (August 13, 2012). "PowerShell Version 3 is RTM!". Under The Stairs. Retrieved August 13, 2012.
- ^ a b c "Windows Management Framework 3.0". Download Center. Microsoft. September 4, 2012. Retrieved November 8, 2012.
- ^ "Windows Management Framework 3.0 Community Technology Preview (CTP) #2 Available for Download". Windows PowerShell Blog. Microsoft. December 2, 2011.
- ^ "Windows Management Framework 3.0". Download Center. Microsoft. December 3, 2012.
- ^ Jofre, JuanPablo (December 14, 2016). "Windows PowerShell System Requirements". Microsoft Developer Network. Microsoft. Retrieved April 20, 2017.
- ^ Honeycutt, Jerry (2012). Woolley, Valerie (ed.). Introducing Windows 8: An Overview for IT Professionals. Redmond, WA: Microsoft Press. ISBN 978-0-7356-7050-1.
- ^ "Windows Management Framework 4.0 is now available". Microsoft. October 24, 2013. Retrieved November 4, 2013.
- ^ Levy, Shay (June 25, 2013). "New Features in Windows PowerShell 4.0". PowerShell Magazine. Retrieved June 26, 2013.
- ^ "Desired State Configuration in Windows Server 2012 R2 PowerShell". Channel 9. Microsoft. June 3, 2013. Archived from the original on December 26, 2013. Retrieved June 26, 2013.
- ^ Hall, Adrian (June 7, 2013). "Thoughts from Microsoft TechEd North America". Blogs: Tips & Tricks. Splunk. Retrieved June 26, 2013.
- ^ "Windows Management Framework (WMF) 5.0 RTM packages has been republished". Windows PowerShell Blog. Microsoft. February 24, 2016.
- ^ "Q and A". GitHub. Retrieved April 21, 2015.
- ^ Snover, Jeffrey (April 3, 2014). "Windows Management Framework V5 Preview". blogs.technet.com. Microsoft. Archived from the original on June 30, 2014. Retrieved April 21, 2015.
- ^ says, Jaap Brasser (August 2, 2016). "#PSTip New PowerShell Commands in Windows 10 Anniversary Update".
- ^ "What's New In Windows Server 2016 Standard Edition Part 9 – Management And Automation". September 4, 2016.
- ^ "Microsoft.PowerShell.LocalAccounts Module". technet.microsoft.com. June 16, 2016.
- ^ "Announcing Windows Management Framework (WMF) 5.1 Preview". July 16, 2016.
- ^ "WMF 5.1". Microsoft Download Center.
- ^ "What is Windows PowerShell? - PowerShell". Microsoft Learn. March 7, 2024. Retrieved August 19, 2024.
- ^ "Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell". Microsoft Learn. April 2, 2024. Retrieved August 19, 2024.
- ^ Aiello, Joey (January 11, 2018). "PowerShell Core 6.0: Generally Available (GA) and Supported!". PowerShell Team Blog. Microsoft. Archived from the original on June 11, 2018. Retrieved June 11, 2018.
- ^ Aiello, Joey; Wheeler, Sean (January 10, 2018). "PowerShell Core Support Lifecycle". Microsoft Docs. Microsoft. Archived from the original on November 16, 2018. Retrieved January 11, 2018.
- ^ Calvo, Angel (January 11, 2018). "Top 10 most exciting reasons to migrate". PowerShell AMA. Microsoft.
- ^ sdwheeler (August 3, 2023). "What's New in PowerShell Core 6.0". learn.microsoft.com. Retrieved December 11, 2023.
Default encoding is UTF-8 without a BOM except for New-ModuleManifest
- ^ a b "Understanding file encoding in VS Code and PowerShell - PowerShell". learn.microsoft.com. November 29, 2023. Retrieved December 11, 2023.
- ^ Aiello, Joey (September 13, 2018). "Announcing PowerShell Core 6.1". devblogs.microsoft.com. Microsoft. Retrieved June 1, 2019.
- ^ "PowerShell/PowerShell". GitHub. Retrieved June 22, 2020.
- ^ a b c Lee, Steve (April 5, 2019). "The Next Release of PowerShell – PowerShell 7". Microsoft. Retrieved June 1, 2019.
- ^ Lee, Steve (March 28, 2019). "General Availability of PowerShell Core 6.2". devblogs.microsoft.com. Microsoft. Retrieved June 1, 2019.
- ^ Mackie, Kurt (May 30, 2019). "Microsoft Releases PowerShell 7 Preview". 1105 Media Inc. Retrieved June 1, 2019.
- ^ Lee, Steve (May 30, 2019). "PowerShell 7 Road Map". devblogs.microsoft.com. Microsoft. Retrieved August 12, 2020.
- ^ "PowerShell 7 Preview 5 | PowerShell". October 23, 2019. Archived from the original on February 15, 2020. Retrieved March 5, 2020.
- ^ "PowerShell 7.2 is the new version of Microsoft's next-generation shell". itsfoss.net. November 12, 2021.
- ^ "Release v7.3.0 Release of PowerShell · PowerShell/PowerShell". GitHub. Archived from the original on November 9, 2022. Retrieved March 7, 2022.
- ^ "Webcmdlets set default charset encoding to UTF8 by CarloToso · Pull Request #18219 · PowerShell/PowerShell". GitHub. Retrieved December 11, 2023.
- ^ "Test-Connection". PowerShell documentations. Microsoft. August 9, 2015.
- ^ "Tar and Curl Come to Windows! - Microsoft Tech Community - 382409". March 22, 2019. Archived from the original on September 11, 2020. Retrieved May 17, 2020.
- ^ Wheeler, Sean (June 2, 2020). "About Scripts". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean; Smatlak, David; Wilson, Chase (October 16, 2019). "How to write a PowerShell module manifest". Docs. Microsoft.
- ^ Wheeler, Sean; Smatlak, David (November 22, 2019). "How to Write a PowerShell Script Module". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean (November 13, 2016). "How to Write a PowerShell Binary Module". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean; Jofre, Juan Pablo; Vorobev, Sergei; Nikolaev, Kirill; Coulter, David (June 2, 2020). "About Types.ps1xml". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean. "Export-Clixml". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean; Jofre, Juan Pablo; Vorobev, Sergei; Nikolaev, Kirill; Coulter, David. "Export-Console". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean (June 2, 2020). "About Session Configuration Files". Microsoft Docs. Microsoft.
- ^ Wheeler, Sean (June 2, 2020). "New-PSRoleCapabilityFile". Microsoft Docs. Microsoft.
- ^ "Microsoft Transporter Suite for Lotus Domino". Microsoft. Retrieved March 7, 2008.
- ^ "PowerTools for Open XML". Retrieved June 20, 2008.
- ^ "MO74: WebSphere MQ – Windows PowerShell Library". Retrieved December 5, 2007.
- ^ "IoT Core Add-ons command-line options". October 15, 2018. Retrieved June 13, 2020.
- ^ "PowerShell Commands for Active Directory by Quest Software". Retrieved July 2, 2008.
- ^ "PowerShell Remoting through Group Policy". Retrieved December 7, 2007.
- ^ "VMware vSphere PowerCLI". Archived from the original on December 30, 2014. Retrieved September 9, 2014.
- ^ "IIS7 PowerShell Provider Tech Preview 2". Windows PowerShell blog. Archived from the original on February 4, 2010. Retrieved July 3, 2008.
- ^ "Kudos to the Win7 Diagnostics Team". Retrieved June 15, 2009.
- ^ Michael, Niehaus (July 10, 2009). "MDT 2010 New Feature #16: PowerShell support". Retrieved October 27, 2014.
- ^ "Kudos to NetApp for Data ONTAP PowerShell ToolKit". Retrieved June 15, 2010.
- ^ "PowerShell Toolkit 4.2 Announcement". June 23, 2016. Retrieved September 7, 2016.
- ^ "Heterogeneous Job Scheduling With PowerShell". Retrieved September 15, 2010.
- ^ "UIAutomation PowerShell Extensions". Archived from the original on August 17, 2016. Retrieved February 16, 2012.
- ^ "EqualLogic HIT-ME with PowerShell". Retrieved March 9, 2012.
- ^ de:LOGINventory
- ^ "Selenium PowerShell eXtensions". Archived from the original on January 19, 2013. Retrieved August 20, 2012.
- ^ "Pash". SourceForge. Dice Holdings, Inc. Retrieved September 27, 2011.
- ^ "Pash Project". GitHub. Retrieved April 10, 2013.
- ^ "Pash is now obsolete · Issue #429 · Pash-Project/Pash". GitHub. Retrieved November 26, 2019.
Further reading
[edit]- Finke, Douglas (2012). Windows PowerShell for Developers. O'Reilly Media. ISBN 978-1-4493-2270-0.
- Holmes, Lee (2006). Windows PowerShell Quick Reference. O'Reilly Media. ISBN 0-596-52813-2.
- Holmes, Lee (2007). Windows PowerShell Cookbook. O'Reilly Media. ISBN 978-0-596-52849-2.
- Jones, Don; Hicks, Jeffery (2010). Windows PowerShell 2.0: TFM (3rd ed.). Sapien Technologies. ISBN 978-0-9821314-2-8.
- Jones, Don (2020). Shell of an Idea: The Untold History of PowerShell. Self-published. ISBN 978-1-9536450-3-6.
- Kopczynski, Tyson; Handley, Pete; Shaw, Marco (2009). Windows PowerShell Unleashed (2nd ed.). Pearson Education. ISBN 978-0-672-32988-3.
- Kumaravel, Arul; White, Jon; Naixin Li, Michael; Happell, Scott; Xie, Guohui; Vutukuri, Krishna C. (2008). Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers. Wrox Press. ISBN 978-0-470-17393-0.
- Oakley, Andy (2005). Monad (AKA PowerShell). O'Reilly Media. ISBN 0-596-10009-4.
- Watt, Andrew (2007). Professional Windows PowerShell. Wrox Press. ISBN 978-0-471-94693-9.
- Wilson, Ed (2013). Windows PowerShell 3.0 Step by Step. Microsoft Press. ISBN 978-0-7356-6339-8.
- Wilson, Ed (2014). Windows PowerShell Best Practices. Microsoft Press. ISBN 978-0-7356-6649-8.
External links
[edit]- Official website
- PowerShell on GitHub
- Windows PowerShell Survival Guide Archived September 15, 2012, at the Wayback Machine on TechNet Wiki
- Windows commands
- .NET programming languages
- Unix shells
- Windows command shells
- Dynamically typed programming languages
- Configuration management
- Free and open-source software
- Interpreters (computing)
- Microsoft free software
- Microsoft programming languages
- Object-oriented programming languages
- Procedural programming languages
- Programming languages created in 2006
- Scripting languages
- Software using the MIT license
- Text-oriented programming languages
- Windows administration
- Formerly proprietary software