PowerShell | |
---|---|
![]() | |
![]() Screenshot of a PowerShell 7.5.0 session inWindows Terminal | |
Paradigm | Imperative,pipeline,object-oriented,functional andreflective |
Designed by | Jeffrey Snover, Bruce Payette, James Truher (et al.) |
Developer | Microsoft |
First appeared | November 14, 2006; 18 years ago (2006-11-14) |
Stable release | |
Preview release | |
Typing discipline | Strong,safe,implicit anddynamic |
Implementation language | C# |
Platform | PowerShell:.NET Windows PowerShell:.NET Framework |
OS |
|
License | MIT License[4] (but the Windows component remainsproprietary) |
Filename extensions |
|
Website | microsoft |
Influenced by | |
Python,Ksh,Perl,C#,CL,DCL,SQL,Tcl,Tk,[5]Chef,Puppet |
PowerShell is ashellprogram developed byMicrosoft for task automation andconfiguration management. As is typical for a shell, it provides acommand-lineinterpreter for interactive use and ascript interpreter for automation via alanguage defined for it. Originally only for Windows, known asWindows PowerShell, it was madeopen-source andcross-platform on August 18, 2016, with the introduction ofPowerShell Core.[6] The former is built on the.NET Framework; the latter on.NET (previously .NET Core).
PowerShell is bundled with currentversions of Windows and can be installed onmacOS andLinux.[6] SinceWindows 10 build 14971, PowerShell replacedCommand Prompt as the defaultcommand shell exposed byFile Explorer.[7][8]
In PowerShell, administrative tasks are generally performed viacmdlets (pronouncedcommand-lets), which are specialized .NETclasses implementing a particular operation. These work by accessing data in different data stores, like thefile system orWindows Registry, which are made available to PowerShell viaproviders. Third-party developers can add cmdlets and providers to PowerShell.[9][10] Cmdlets may be used by scripts, which may in turn be packaged into modules. Cmdlets work in tandem with the .NETAPI.
PowerShell's support for.NET Remoting,WS-Management,CIM, andSSH enables administrators to perform administrative tasks on both local and remote Windows systems. PowerShell also provides a hostingAPI 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 thegraphical interface. This capability has been used byMicrosoft Exchange Server 2007 to expose its management functionality as PowerShell cmdlets and providers and implement thegraphical management tools as PowerShell hosts which invoke the necessary cmdlets.[9][11] Other Microsoft applications includingMicrosoft SQL Server 2008 also expose their management interface via PowerShell cmdlets.[12]
PowerShell includes its own extensive,console-based help (similar toman pages inUnix shells) accessible via theGet-Help
cmdlet. Updated local help contents can be retrieved from the Internet via theUpdate-Help
cmdlet. Alternatively, help from the web can be acquired on a case-by-case basis via the-online
switch toGet-Help
.
Shell programs, including PowerShell, trace lineage to shells in olderoperating systems such asMS-DOS andXenix which exposed system functionality to the user almost exclusively via acommand-line interface (CLI) – althoughMS-DOS 5 also came with a complementary graphicalDOS Shell. TheWindows 9x family came bundled withCOMMAND.COM, the command-line environment of MS-DOS. TheWindows NT andWindows CE families, however, came with the newercmd.exe – a significant upgrade from COMMAND.COM. Both environments provide CLI for both internal and external commands and automation viabatch files – a relatively primitive language for scripting.
To address limitations of these shells – including the inability to directly use asoftware component exposed viaCOM – Microsoft introduced theWindows Script Host in 1998 withWindows 98, and its command-line based host,cscript.exe
. It integrates with theActive Script engine and allows scripts to be written in compatible languages, such asJScript andVBScript. These scripts can use COM components directly, but it has relatively inaccessible documentation and gained a reputation as a systemvulnerability vector after several high-profilecomputer viruses exploited weaknesses in its security provisions.
Different versions of Windows provided various special-purpose command-line interpreters (such asnetsh andWMIC) 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.[13]
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 onSun Microsystems computers which ranSolaris (aUnix variant) onRISC-architecture CPUs. The ability to run Intel's manyKornShell 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.[14] Intel ultimately pivoted to aLinux-based development platform that could run on Intel CPUs, rendering the Kermit project redundant. However, with a fully funded team, Microsoft program managerJeffrey Snover realized there was an opportunity to create a more general-purpose solution to Microsoft's problem of administrative automation.
By 2002, Microsoft had started to develop a new approach to command-line management, including a CLI called Monad (also known asMicrosoft 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.[15] In a 2017 interview, Snover explains the genesis of PowerShell, saying that he had been trying to makeUnix tools available on Windows, which didn't work due to "core architectural difference[s] between Windows and Linux". Specifically, he noted thatLinux considers everything atext file, whereas Windows considers everything an "API that returns structured data". They were fundamentally incompatible, which led him to take a different approach.[16]
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 publicbeta release on June 17, 2005, and the Beta 2 on September 11, 2005, and Beta 3 on January 10, 2006.
On April 25, 2006, not long after the initial Monad announcement, Microsoft announced that Monad had been renamedWindows PowerShell, positioning it as a significant part of its management technology offerings.[17] 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 finalrelease to the web on November 14, 2006. PowerShell for earlier versions of Windows was released on January 30, 2007.[18] PowerShell v2.0 development began before PowerShell v1.0 shipped. During the development, Microsoft shipped threecommunity 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.[19] In an October 2009 issue ofTechNet Magazine, Microsoft called proficiency with PowerShell "the single most important skill a Windowsadministrator will need in the coming years".[20]
Windows 10 shipped with Pester, a script validation suite for PowerShell.[21]
On August 18, 2016, Microsoft announced[22] that they had made PowerShell open-source and cross-platform with support for Windows,macOS,CentOS andUbuntu.[6] The source code was published onGitHub.[23] 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.[24] Starting with version 5.1, PowerShell Core is bundled withWindows Server 2016 Nano Server.[25][26]
A project namedPash, apun on the widely known "bash" Unix shell, has been anopen-source andcross-platform reimplementation of PowerShell via theMono framework.[27] Pash was created by Igor Moochnick, written inC# and was released under theGNU General Public License. Pash development stalled in 2008, was restarted onGitHub in 2012,[28] and finally ceased in 2016 when PowerShell was officially made open-source and cross-platform.[29]
A key design goal for PowerShell was to leverage the large number ofAPIs that already existed in Windows, Windows Management Instrumentation, .NET Framework, and other software. PowerShell cmdlets generally wrap and expose existing functionality instead of implementing new functionality. The intent was 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.[30]
PowerShell's developers based the core grammar of the tool on that of thePOSIX 1003.2KornShell.[31]
However, PowerShell's language was also influenced byPHP,Perl, and many other existing languages.[32]
PowerShell can execute four kinds of named commands:[33]
.ps1
)If a command is a standalone executable program, PowerShell launches it in a separateprocess; if it is a cmdlet, it executes in the PowerShell process. PowerShell provides an interactivecommand-line interface, where the commands can be entered and their output displayed. The user interface offers customizabletab completion. PowerShell enables the creation ofaliases for cmdlets, which PowerShell textually translates into invocations of the original commands. PowerShell supports bothnamed and positionalparameters 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.[34]
The PowerShellExtended 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 usingXML-based configuration files.[35]
A cmdlet is a .NETclass that derives either fromCmdlet
or fromPSCmdlet
; the latter used when it needs to interact with the PowerShell runtime.[36] The base classes specify methods –BeginProcessing()
,ProcessRecord()
andEndProcessing()
– which a cmdlet overrides to provide functionality based on the events that these functions represent.ProcessRecord()
is called if the object receives pipeline input.[37] If a collection of objects is piped, the method is invoked for each object in the collection. The cmdlet class must have theattributeCmdletAttribute
which specifies the verb and the noun that make up the name of the cmdlet.
A cmdlet name follows aVerb-Noun naming pattern, such asGet-ChildItem, which tends to make itself-documented.[36] Common verbs are provided as anenum.[38][39]
If a cmdlet receives either pipeline input or command-line parameter input, there must be a correspondingproperty in the class, with amutator 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 byParameterAttribute
[40] and are set before the call toBeginProcessing()
. Those which map to pipeline input are also flanked byParameterAttribute
, but with theValueFromPipeline
attribute parameter set.[41]
A cmdlet can use any.NETAPI and may be written in any.NET language. In addition, PowerShell makes certain APIs available, such asWriteObject()
, which is used to access PowerShell-specific functionality, such as writing objects to the pipeline. A cmdlet can use .NET a data accessAPI directly or use the PowerShell infrastructure ofProviders, which make data stores addressable using uniquepaths. Data stores are exposed usingdrive letters, and hierarchies within them, addressed as directories. PowerShell ships with providers for thefile system,registry, thecertificate store, as well as thenamespaces for command aliases, variables, and functions.[42] PowerShell also includes various cmdlets for managing variousWindows systems, including thefile system, or usingWindows Management Instrumentation to controlWindows 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]
A cmdlet can be added to the shell via modules or before v2 snap-ins. Users are not limited to the cmdlets included in the base PowerShell installation.
The number of cmdlets included in the base PowerShell install for various versions:
To enablepipelinesemantics, similar to theUnix pipeline, a cmdlet receives input and outputs result as objects. If a cmdlet outputs multiple objects, each object of the collection is passed through the pipeline before the next object is processed.[36] A PowerShell pipeline enables complex logic using the pipe (|
) operator to connect stages. However, the PowerShell pipeline differs from Unix pipelines in that stages executewithin the PowerShell runtime rather than as a set of processes coordinated by theoperating system. Additionally, structured .NET objects, rather thanbyte streams, are passed from one stage to the next. Usingobjects and executing stages within the PowerShell runtime eliminates the need toserialize data structures, or to extract them by explicitlyparsing text output.[47] An object can alsoencapsulate certain functions that work on the contained data, which become available to the recipient command for use.[48][49] For the last cmdlet in a pipeline, PowerShell automatically pipes its output object to theOut-Default
cmdlet, which transforms the objects into a stream of format objects and then renders those to the screen.[50][51]
Because a PowerShell object is a .NET object, it has a.ToString()
method which is used to serialize object state. 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 maintainbackward 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.[52][53][54]
PowerShell includes adynamically typedlanguage for scripting which can implement complex operations using cmdletsimperatively. The language supports variables, functions, branching (if-then-else
), loops (while
,do
,for
, andforeach
), structured error/exception handling andclosures/lambda expressions,[55] 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 anL-value, anything assigned to it will be written to the file. When used as anR-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.[56] PowerShell also providesarrays andassociative arrays. The PowerShell language also evaluates arithmetic expressions entered on the command line immediately, and it parses common abbreviations, such as GB, MB, and KB.[57][58]
Using thefunction
keyword, PowerShell provides for the creation of functions. A simple function has the following general look:[59]
functionname([Type]$Param1,[Type]$Param2){# Instructions}
However, PowerShell allows for advanced functions that support named parameters, positional parameters, switch parameters and dynamic parameters.[59]
functionVerb-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:[59]
namevalue1value2Verb-Noun-Param1value1-Param2value2
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.[60] 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.[60]
PowerShell acceptsstrings, both raw andescaped. A string enclosed between singlequotation 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.[61]
The following list of special characters is supported by PowerShell:[62]
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-basedexception-handling mechanism. In case of errors, objects containing information about the error (Exception
object) are thrown, which are caught using thetry ... catch
construct (although atrap
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.[63]
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.[64] Enabling of scripts can be performed either at system, user or session level. PowerShell scripts can besigned to verify their integrity, and are subject toCode Access Security.[65]
The PowerShell language supportsbinary prefix notation similar to thescientific notation supported by many programming languages in the C-family.[66]
One can also use PowerShell embedded in a management application, which uses the PowerShell runtime to implement the management functionality. For this, PowerShell provides amanaged hostingAPI. Via the APIs, the application can instantiate arunspace (one instantiation of the PowerShell runtime), which runs in the application'sprocess and is exposed as aRunspace
object.[9] The state of the runspace is encased in aSessionState
object. When the runspace is created, the PowerShell runtime initializes the instantiation, including initializing the providers and enumerating the cmdlets, and updates theSessionState
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 aPipeline
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.[9] When a pipeline is created, PowerShell invokes the pipeline processor, which resolves the cmdlets into their respectiveassemblies (thecommand processor) and adds a reference to them to the pipeline, and associates them withInputPipe
,OutputPipe
andErrorOutputPipe
objects, to represent the connection with the pipeline. The types are verified and parameters bound usingreflection.[9] Once the pipeline is set up, the host calls theInvoke()
method to run the commands, or its asynchronous equivalent,InvokeAsync()
. If the pipeline has theWrite-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, whichinterprets the scripts entered at command line and creates the necessaryPipeline
objects and invokes them.[citation needed]
DSC allows for declaratively specifying how a software environment should be configured.[67]
Upon running aconfiguration, DSC will ensure that the system gets the state described in the configuration. DSC configurations are idempotent. TheLocal Configuration Manager (LCM) periodically polls the system using the control flow described byresources (imperative pieces of DSC) to make sure that the state of a configuration is maintained.
All major releases are still supported, and each major release has featured backwards compatibility with preceding versions.[dubious –discuss]
Initially using the code name "Monad", PowerShell was first shown publicly at the Professional Developers Conference in October 2003 in Los Angeles.
Named Windows PowerShell, version 1.0 was released in November 2006 forWindows XP SP2,Windows Server 2003 SP1 andWindows Vista[68] and as an optional component ofWindows Server 2008.
Version 2.0 integrates withWindows 7 andWindows Server 2008 R2[69] and is released forWindows XP with Service Pack 3,Windows Server 2003 with Service Pack 2, andWindows Vista with Service Pack 1.[70][71]
The version includes changes to the language and hosting API, in addition to including more than 240 new cmdlets.[72][73]
New features include:[74][75][76]
BeginProcessing()
,ProcessRecord()
andEndProcessing()
functions of a cmdlet are called.Out-GridView
, which displays tabular data in theWPFGridView object, on systems that allow it, and if ISE is installed and enabled.-Split
,-Join
, and Splatting (@
) operators.<#
and#>
as delimiters.[80]RunspacePools
) as well as the ability to createRestricted Runspaces which only allow a configured subset of PowerShell to be invoked. The new APIs also support participation in a transactionVersion 3.0 integrates withWindows 8,Windows Server 2012,Windows 7 with Service Pack 1,Windows Server 2008 with Service Pack 1, andWindows Server 2008 R2 with Service Pack 1.[81][82]
Version 3.0 is part of a larger package,Windows Management Framework 3.0 (WMF3), which also contains theWinRM service to support remoting.[82] Microsoft made severalCommunity 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.[83] Windows Management Framework 3.0 was released for general availability in December 2012[84] and is included with Windows 8 and Windows Server 2012 by default.[85]
New features include:[82][86]: 33–34
get-WmiObject win32_logicaldisk
, volumes, firewalls, network connections, and printers, which had previously been performed via WMI.[further explanation needed]Version 4.0 integrates withWindows 8.1,Windows Server 2012 R2,Windows 7 SP1,Windows Server 2008 R2 SP1 andWindows Server 2012.[87]
New features include:
RemoteSigned
.Version 5.0 was re-released with Windows Management Framework (WMF) 5.0 on February 24, 2016, following an initial release with a severe bug.[91]
Key features included:
class
keyword that createsclasses forobject-oriented programmingenum
keyword that createsenumsOneGet
cmdlets to support theChocolateypackage manager[92]Version 5.1 was released along with theWindows 10 Anniversary Update[94] on August 2, 2016, and inWindows Server 2016.[95] 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.[96] A preview for was released for Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2 on July 16, 2016,[97] and was released on January 19, 2017.[98]
Version 5.1 is the first to come in two editions of "Desktop" and "Core". The "Desktop" edition is the continuation product line that uses the .NET Framework, and 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.[26] This was the final version exclusively for Windows. Version 5.1 remains pre-installed on Windows 10, Windows 11 and Windows Server 2022, while the .NET version needs to be installed separately and can run side-by-side with the .NET Framework version.[99][100]
Renamed to PowerShell Core, version 6.0 was first announced on August 18, 2016, when Microsoft unveiled its decision to make the productcross-platform, independent of Windows, free and open source.[6] It achievedgeneral availability on January 10, 2018, for Windows,macOS andLinux.[101] 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.[102]
The most significant change in this version is the expansion to the other platforms. For Windows administrators, this version did not include any major new features. In an interview with the community on January 11, 2018, the development team was asked to list the top 10 most exciting things that would happen for a Windows IT professional who would migrate from version 5.1 to version 6.0. In response, Angel Calvo of Microsoft could only name two: cross-platform and open-source.[103] PowerShell 6 changed toUTF-8 as default encoding, with some exceptions.[104] (version 7.4 changes more to UTF-8)[105]
According to Microsoft, one of the new features of version 6.1 is "Compatibility with 1900+ existing cmdlets in Windows 10 andWindows Server 2019."[106] Still, no details of these cmdlets can be found in the full version of the change log.[107] Microsoft later professes that this number was insufficient as PowerShell Core failed to replace Windows PowerShell 5.1 and gain traction on Windows.[108] It was, however, popular on Linux.[108]
Version 6.2 is focused primarily on performance improvements, bug fixes, and smaller cmdlet and language enhancements that improved developer productivity.[109]
Renamed to simply PowerShell, version 7 replaces the previous product lines: PowerShell Core and Windows PowerShell.[110][108] The focus in development was to make version 7 a viable replacement for version 5.1, i.e. to have near parity with it in terms of compatibility with modules that ship with Windows.[111]
New features include:[112]
-Parallel
switch for theForEach-Object
cmdlet to help handle parallel processingGet-Error
cmdlet&&
and||
) that allow conditional execution of the next cmdlet in the pipeline??
operator fornull coalescing??=
operator for null coalescing assignmentInvoke-DscResource
(experimental)Out-GridView
cmdlet-ShowWindow
switch for theGet-Help
Version 7.2 is the next long-term support version, after version 7.0. It uses .NET 6.0 and features universal installer packages for Linux. On Windows, updates to version 7.2 and later come via theMicrosoft Update service; this feature has been missing from versions 6.0 through 7.1.[113]
Version 7.3 includes some general Cmdlet updates and fixes, testing for framework dependent package in release pipeline as well as build and packaging improvements.[114]
Version 7.4 is based on .NET 8 and is considered the long term support (LTS) release.[115]
Changes include:[116]
Version 7.5, is the latest stable release; released January 2025; built on .NET 9.0.1. It includes enhancements for performance, usability, and security.[117] Key updates include improvements to tab completion, such as better type inference and new argument completers, as well as fixes for Invoke-WebRequest and Invoke-RestMethod. This release also adds the new ConvertTo-CliXml and ConvertFrom-CliXml cmdlets, and updates core modules like PSReadLine and Microsoft.PowerShell.PSResourceGet. Breaking changes include updates to Test-Path parameter handling, and default settings for New-FileCatalog.
Prior to GA Release there were 5 preview releases and 1 RC release of PowerShell v7.5.0,[118] with a full release blog post for this version expected soon.
Version 7.6 is based on .NET 9 and is the latest preview release. The first preview release v7.6.0-preview.2[119] was released on January 15, 2025.
Changes include: TBD[120]
The following table contains various cmdlets that ship with PowerShell that have notably similar functionality to commands in other shells. Many of these cmdlets are exposed to the user via predefined aliases to make their use familiar to users of the other shells.
Cmdlet | Predefined alias | Command Prompt command | Unix shell command | Functionality |
---|---|---|---|---|
Clear-Host[a] | cls,clear | cls | clear | Clears the screen |
Copy-Item | cpi,copy,cp | copy | cp | Copies files and folders |
Get-ChildItem | gci, dir, ls[b] | dir | ls | Lists files and folders |
Get-Command | gcm | help,where | type,which,compgen | Lists available commands and gets command path |
Get-Content | gc,type,cat | type | cat | Reports the content of a file |
Get-Date | {{{1}}} | date +time | date | Reports date and time |
Get-Help | help,man[c] | help | apropos,man | Reports a command's documentation |
Get-History | ghy,h,history | DOSKEY /HISTORY | fc -l,history[d] | Lists previous commands |
Get-Location | gl,pwd | cd | pwd | Reports theworking directory |
Get-Process | gps,ps | tlist,[e]tasklist[f] | ps | Reports running processes |
Invoke-WebRequest | iwr, | curl[121] | wget,curl | Downloads contents from the Internet |
Measure-Object | measure | — | wc (Unix) | Counts characters, words and lines of text. Powershell adds summaries of numeric properties of objects |
Move-Item | mi,move,mv | move | mv | Moves files and folders |
Pop-Location | popd | popd | popd | Reverts the working directory to the path last pushed |
Push-Location | pushd | pushd | pushd | Pushes the working directory path and changes the working directory |
Read-Host | {{{1}}} | set /P | read | Reads input into a variable from the command line |
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 file or folder |
Register-ScheduledJob | — | at, schtasks[122] | at,cron | Schedule tasks to be run at a different time |
Select-String | sls | find,findstr | grep | Reports lines of a file that match a pattern |
Set-Date | {{{1}}} | date +time | date -s | Resets the date and time |
Set-Location | sl,cd,chdir | cd,chdir | cd | Changes the working path |
Set-Variable | sv,set | set | env,export,set,setenv | Creates or alters the contents of anenvironment variable |
Sort-Object | sort | sort | sort | Sorts lines of text; cmdlet also sorts objects |
Stop-Process | spps,kill | kill,[e]taskkill[f] | kill[h] | Stops a running process |
Tee-Object | tee | — | tee | Pipes input to a file or variable, passing the input along the pipeline |
Test-Connection[i] | ping | ping | ping | SendsICMP echo requests to a remote machine |
Write-Output | echo,write | echo | echo | Writes text tostandard output |
Notes
ls
is absent from the Linux version of PowerShell Coreman
is absent from the Linux version of PowerShell Corecurl
andwget
are absent from PowerShell Core, so as to not interfere with similarly named native commandsExtension | Description |
---|---|
.ps1 | Script file[124] |
.psd1 | Module's manifest file; usually comes with a script module or binary module[125] |
.psm1 | Script module file[126] |
.ps1xml | Format and type definitions file[54][127] |
.psc1 | Console file[128] |
.pssc | Session configuration file[129] |
.psrc | Role Capability file[130] |
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 forLotus Domino[131] | 08.02.0012 | 47 | No | No |
Microsoft PowerTools forOpen XML[132] | 1.0 | 33 | No | No |
IBM WebSphere MQ[133] | 6.0.2.2 | 44 | No | No |
IoT Core Add-ons[134] | 74 | Unknown | Unknown | |
Quest Management Shell for Active Directory[135] | 1.7 | 95 | No | No |
Special Operations Software Specops Command[136] | 1.0 | Yes | No | Yes |
VMware vSphere PowerCLI[137] | 6.5 R1 | 500+ | Yes | Yes |
Internet Information Services[138] | 7.0 | 54 | Yes | No |
Windows 7 Troubleshooting Center[139] | 6.1 | Yes | No | Yes |
Microsoft Deployment Toolkit[140] | 2010 | Yes | Yes | Yes |
NetApp PowerShell Toolkit[141][142] | 4.2 | 2000+ | Yes | Yes |
JAMS Scheduler – Job Access & Management System[143] | 5.0 | 52 | Yes | Yes |
UIAutomation[144] | 0.8 | 432 | No | No |
Dell Equallogic[145] | 3.5 | 55 | No | No |
LOGINventory[146] | 5.8 | Yes | Yes | Yes |
SePSX[147] | 0.4.1 | 39 | No | No |
A standout feature here is that virtually all admin utilities now work from the command line (and most are available through telnet).
The core PowerShell language is based on the POSIX 1003.2 grammar for theKorn shell.
Windows PowerShell 3.0 comes with about 1,000 cmdlets on Windows 8
Windows PowerShell 5.0 comes with about 1,300 cmdlets on Windows 10
Default encoding is UTF-8 without a BOM except for New-ModuleManifest