PowerShell explained

PowerShell
Screenshot Caption:Screenshot of a PowerShell 7 session in Windows Terminal
Paradigm:Imperative, pipeline, object-oriented, functional and reflective
Designer:Jeffrey Snover, Bruce Payette, James Truher (et al.)
Developer:Microsoft
Latest Release Version:7.4.3
Latest Release Date:[1]
Typing:Strong, safe, implicit and dynamic
Programming Language:C#
Platform:PowerShell: .NET
Windows PowerShell: .NET Framework
License:MIT License[2] (but the Windows component remains proprietary)
Influenced By:Python, Ksh, Perl, C#, CL, DCL, SQL, Tcl, Tk,[3] 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. 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. Since Windows 10 build 14971, PowerShell replaced Command Prompt (cmd.exe) and became the default command shell for File Explorer.[4] [5]

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.[6] 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.[7] Other Microsoft applications including Microsoft SQL Server 2008 also expose their management interface via PowerShell cmdlets.[8]

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

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 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.[9]

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 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.[10] 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

By 2002, Microsoft had started to develop a new approach to command-line management, including a CLI called Monad (also known as 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.[11] 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.[12]

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

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.[13] 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.[14] 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.[15] 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".[16]

Windows 10 shipped with Pester, a script validation suite for PowerShell.[17]

On August 18, 2016, Microsoft announced[18] that they had made PowerShell open-source and cross-platform with support for Windows, macOS, CentOS and Ubuntu.[19] The source code was published on GitHub.[20] 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.[21] Starting with version 5.1, PowerShell Core is bundled with Windows Server 2016 Nano Server.[22] [23]

Design

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.[24]

Grammar

PowerShell's developers based the core grammar of the tool on that of the POSIX 1003.2 KornShell.[25]

However, PowerShell's language was also influenced by PHP, Perl, and many other existing languages.[26]

Named Commands

Windows PowerShell can execute four kinds of named commands:[27]

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.[28]

Extended Type System

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.[29]

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.[30] 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.

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. 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.[31] 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 attributeCmdletAttribute – which specifies the verb and the noun that make up the name of the cmdlet. Common verbs are provided as an enum.[32] [33]

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[34] 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.[35]

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.[36] 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.

The number of cmdlets included in the base PowerShell install has generally increased with each version:

Versiondata-sort-type="number" Cmdlets Ref
Windows PowerShell 1.0[37]
Windows PowerShell 2.0[38]
Windows PowerShell 3.0 [39]
Windows PowerShell 4.0
Windows PowerShell 5.0[40]
Windows PowerShell 5.1
PowerShell Core 6.0
PowerShell Core 6.1
PowerShell Core 6.2
PowerShell 7.0
PowerShell 7.1
PowerShell 7.2
PowerShell 7.4

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

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.[41] An object can also encapsulate certain functions that work on the contained data, which become available to the recipient command for use.[42] [43] 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.[44] [45]

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.[46] [47] [48]

Scripting

Windows PowerShell includes a dynamically typed scripting language which can implement complex operations using cmdlets imperatively. The scripting language supports variables, functions, branching ([[conditional (programming)|if-then-else]]), loops ([[while loop|while]], [[do while loop|do]], [[for loop|for]], and [[foreach]]), structured error/exception handling and closures/lambda expressions,[49] 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.

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.[50] 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.[51] [52]

Using the function keyword, PowerShell provides for the creation of functions. A simple function has the following general look:function name ([Type]$Param1, [Type]$Param2)

However, PowerShell allows for advanced functions that support named parameters, positional parameters, switch parameters and dynamic parameters.function Verb-Noun

The defined function is invoked in either of the following forms:[53] name value1 value2Verb-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.[54] 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.

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.[55]

The following list of special characters is supported by PowerShell:[56]

PowerShell special characters
SequenceMeaning
Null
Alert
Backspace
Escape (since PowerShell 6)
Form feed
Newline
Carriage return
Horizontal tab
Unicode escape sequence (since PowerShell 6)
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.[57]

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.[58] 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.[59]

The PowerShell scripting language supports binary prefix notation similar to the scientific notation supported by many programming languages in the C-family.[60]

Hosting

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. 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.

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. 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. 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.

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.

Desired State Configuration

DSC allows for declaratively specifying how a software environment should be configured.[61]

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

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

PowerShell 1.0 was released in November 2006 for Windows XP SP2, Windows Server 2003 SP1 and Windows Vista.[62] It is an optional component of Windows Server 2008.

Windows PowerShell 2.0

PowerShell 2.0 is integrated with Windows 7 and Windows Server 2008 R2[63] and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, and Windows Vista with Service Pack 1.[64] [65]

PowerShell v2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.[66] [67]

New features of PowerShell 2.0 include:[68] [69] [70]

Windows PowerShell 3.0

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.[75] [76]

PowerShell 3.0 is part of a larger package, Windows Management Framework 3.0 (WMF3), which also contains the WinRM service to support remoting. 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.[77] Windows Management Framework 3.0 was released for general availability in December 2012[78] and is included with Windows 8 and Windows Server 2012 by default.[79]

New features in PowerShell 3.0 include:[80]

Windows PowerShell 4.0

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.[81]

New features in PowerShell 4.0 include:

Windows PowerShell 5.0

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.[85]

Key features included:

Windows PowerShell 5.1

It was released along with the Windows 10 Anniversary Update[88] on August 2, 2016, and in Windows Server 2016.[89] 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.[90] 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,[91] and was released on January 19, 2017.[92]

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. 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 seperately and can run side-by-side with Windows PowerShell.[93] [94]

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, independent of Windows, free and open source. It achieved general availability on January 10, 2018, for Windows, macOS and Linux.[95] 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.[96]

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.[97] PowerShell 6 changed to UTF-8 as default encoding, with some exceptions.[98] (PowerShell 7.4 changes more to UTF-8)[99]

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."[100] Still, no details of these cmdlets can be found in the full version of the change log.[101] Microsoft later professes that this number was insufficient as PowerShell Core failed to replace Windows PowerShell 5.1 and gain traction on Windows. It was, however, popular on Linux.

6.2

PowerShell Core 6.2 is focused primarily on performance improvements, bug fixes, and smaller cmdlet and language enhancements that improved developer productivity.[102]

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.[103] [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.[105]

New features in PowerShell 7 include:[106]

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.[107]

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.[108]

PowerShell 7.4

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).[109] 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.

Comparison of PowerShell cmdlets with internal and external commands of other command-line interpreters
PowerShell (Cmdlet)PowerShell (Alias)Windows Command Prompt<--Not COMMAND.COM! Far too many of these don't apply to COMMAND.COM.-->Unix shellDescription
Lists all files and folders in the current or given folder
Sends ICMP echo requests to the specified machine from the current machine, or instructs another machine to do so
Gets the content of a file
Lists available commands and gets command path
Prints a command's documentation on the console
Clears the screen
Copies files and folders to another location
Moves files and folders to a new location
Deletes files or folders
Renames a single file, folder, hard link or symbolic link
Displays the working path (current folder)
Changes the working path to the location most recently pushed onto the stack
Stores the working path onto the stack
Changes the working path
Pipes input to a file or variable, passing the input along the pipeline
Prints strings or other objects to the standard output
, Lists all running processes
Stops a running process
, Prints lines matching a pattern
Creates or alters the contents of an environment variable
Gets contents from a web page on the Internet
Notes

Filename extensions

ExtensionDescription
.ps1 Script file[110]
.psd1 Module's manifest file; usually comes with a script module or binary module[111]
.psm1 Script module file[112]
.dll DLL-compliant binary module file[113]
.ps1xml Format and type definitions file[114]
.xml XML-compliant serialized data file[115]
.psc1 Console file[116]
.pssc Session configuration file[117]
.psrc Role Capability file[118]

Application support

ApplicationVersiondata-sort-type="number" Cmdlets ProviderManagement GUI
Exchange Server2007
Windows Server2008
Microsoft SQL Server2008
Microsoft SharePoint2010
System Center Configuration Manager2012 R2
System Center Operations Manager2007
System Center Virtual Machine Manager2007
System Center Data Protection Manager2007
Windows Compute Cluster Server2007
Microsoft Transporter Suite for Lotus Domino[119] 08.02.0012
Microsoft PowerTools for Open XML[120] 1.0
IBM WebSphere MQ[121] 6.0.2.2
IoT Core Add-ons[122]
Quest Management Shell for Active Directory[123] 1.7
Special Operations Software Specops Command[124] 1.0
VMware vSphere PowerCLI[125] 6.5 R1
Internet Information Services[126] 7.0
Windows 7 Troubleshooting Center[127] 6.1
Microsoft Deployment Toolkit[128] 2010
NetApp PowerShell Toolkit[129] [130] 4.2
JAMS Scheduler – Job Access & Management System[131] 5.0
UIAutomation[132] 0.8
Dell Equallogic[133] 3.5
LOGINventory[134] 5.8
SePSX[135] 0.4.1

Alternative implementation

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.[136] 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,[137] and finally ceased in 2016 when PowerShell was officially made open-source and cross-platform.[138]

See also

Further reading

External links

Notes and References

  1. Web site: Release v7.4.3 Release of PowerShell · PowerShell/PowerShell . 2024-07-01 . PowerShell/PowerShell repo . . . en.
  2. Web site: PowerShell for every system!. June 12, 2017. GitHub.com.
  3. Web site: Snover . Jeffrey . PowerShell and WPF: WTF . May 25, 2008 . Windows PowerShell Blog . Microsoft .
  4. Web site: Announcing Windows 10 Insider Preview Build 14971 for PC.
  5. Web site: PowerShell is replacing Command Prompt.
  6. Truher . Jim . December 2007 . Extend Windows PowerShell With Custom Commands. . Microsoft . https://web.archive.org/web/20081006195551/http://msdn.microsoft.com/en-us/magazine/cc163293.aspx . October 6, 2008.
  7. Web site: Exchange 2007: Get used to the command line. Lowe. Scott. January 4, 2007. TechRepublic. CBS Interactive. live. https://web.archive.org/web/20181116084157/https://www.techrepublic.com/article/exchange-2007-get-used-to-the-command-line/. November 16, 2018. May 12, 2020.
  8. Web site: SQL Server Support for PowerShell!. Snover. Jeffrey. November 13, 2007. Windows PowerShell Blog. Microsoft. blog posting. https://web.archive.org/web/20071115215316/http://blogs.msdn.com/powershell/archive/2007/11/13/sql-server-support-for-powershell.aspx. November 15, 2007. November 13, 2007.
  9. Web site: Dragan . Richard V. . April 23, 2003 . Windows Server 2003 Delivers Improvements All Around . . . A standout feature here is that virtually all admin utilities now work from the command line (and most are available through telnet)..
  10. Book: Jones . Don . Shell of an Idea: The Untold History of PowerShell . 2020 . 978-1-9536450-3-6 . 25. Don Gannon-Jones .
  11. News: Jeffrey P. Snover . Monad Manifesto . April 2, 2021 . Windows PowerShell Blog . Microsoft . August 8, 2002.
  12. The Man Behind Windows PowerShell. Heavybit. To Be Continuous. Biggar and Harbaugh. September 14, 2017. September 14, 2017.
  13. Web site: Windows PowerShell (Monad) Has Arrived . April 25, 2006. Windows PowerShell Blog . Microsoft.
  14. Web site: Windows PowerShell & Windows Vista . blog posting . November 15, 2006. Snover . Jeffrey . Windows PowerShell Blog . Microsoft.
  15. Web site: Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) . Support . . September 30, 2013. dead . October 13, 2013. https://web.archive.org/web/20131013100052/http://support.microsoft.com/kb/968929.
  16. News: Posey . Brien . 10 reasons why you should learn to use PowerShell . April 2, 2021 . TechRepublic . October 6, 2009.
  17. Web site: What is Pester and Why Should I Care?. December 14, 2015.
  18. Web site: PowerShell is open sourced and is available on Linux . Microsoft Azure Blog . Microsoft. August 18, 2016 . Jeffrey . Snover.
  19. Web site: PowerShell is Microsoft's latest open source release, coming to Linux, OS X. Bright. Peter. August 18, 2016. Ars Technica. Condé Nast. live. 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/. April 9, 2020. May 12, 2020.
  20. Web site: PowerShell/PowerShell. GitHub. August 18, 2016.
  21. Web site: Hansen. Kenneth. Calvo. Angel. PowerShell on Linux and Open Source!. Windows PowerShell Blog. Microsoft. August 18, 2016.
  22. Web site: Microsoft open sources PowerShell; brings it to Linux and Mac OS X . . . Mary Jo . Foley . Mary Jo Foley . August 18, 2016.
  23. Web site: PowerShell on Nano Server. October 20, 2016. TechNet. Microsoft.
  24. Book: Jones . Don . Shell of an Idea: The Untold History of PowerShell . 2020 . 978-1-9536450-3-6 . 45. Don Gannon-Jones .
  25. Book: Payette. Bruce. Windows PowerShell in Action. Manning Pubs Co Series. Manning. 2008. 27. 9781932394900. July 22, 2016. The core PowerShell language is based on the POSIX 1003.2 grammar for the Korn shell..
  26. Book: Jones . Don . Shell of an Idea: The Untold History of PowerShell . 2020 . 978-1-9536450-3-6 . 109. Don Gannon-Jones .
  27. Web site: about_Command_Precedence . . . May 8, 2014.
  28. Web site: Wheeler. Sean. September 7, 2021. about Parsing - PowerShell. December 5, 2021. Microsoft Docs.
  29. Web site: Windows PowerShell Extended Type System . November 28, 2007.
  30. Web site: Windows PowerShell Cmdlets . November 28, 2007.
  31. Web site: Creating Your First Cmdlet . November 28, 2007.
  32. Web site: Get-Verb . . . May 8, 2014.
  33. Web site: Cmdlet Overview . . . May 8, 2014.
  34. Web site: Adding parameters That Process Command Line Input . November 28, 2007.
  35. Web site: Adding parameters That Process Pipeline Input . November 28, 2007.
  36. Web site: Windows PowerShell Providers . October 14, 2010.
  37. Web site: PowerShell 1.0 Cmdlets. Yoshizawa. Tomoaki. Ramos. Durval. September 29, 2012. TechNet Articles. Microsoft.
  38. Web site: PowerShell 2.0 Cmdlets. Yoshizawa. Tomoaki. July 10, 2012. TechNet Articles. Microsoft.
  39. Book: Wilson, Ed. Windows Powershell 3.0 Step by Step. 2013. Microsoft Press. 978-0-7356-7000-6. Sebastopol, California. 1: Overview of Windows PowerShell 3.0. 829236530. Windows PowerShell 3.0 comes with about 1,000 cmdlets on Windows 8. https://www.microsoftpressstore.com/articles/article.aspx?p=2201304.
  40. Book: Wilson, Ed. Windows PowerShell Step by Step. Microsoft Press. 978-1-5093-0043-3. Third. Redmond, Washington. 1: Overview of Windows PowerShell 5.0. 2015. 927112976. Windows PowerShell 5.0 comes with about 1,300 cmdlets on Windows 10. https://www.microsoftpressstore.com/articles/article.aspx?p=2449029.
  41. Web site: Windows PowerShell Owner's Manual: Piping and the Pipeline in Windows PowerShell . . . September 27, 2011.
  42. Web site: Windows PowerShell – Rethinking the Pipeline . Don . Jones. 2008. . . November 28, 2007.
  43. Web site: Windows PowerShell Object Concepts . November 28, 2007 . dead . https://web.archive.org/web/20070819233213/http://msdn2.microsoft.com/en-us/library/aa347685.aspx . August 19, 2007 .
  44. Web site: How PowerShell Formatting and Outputting REALLY works. November 28, 2007.
  45. Web site: More – How does PowerShell formatting really work? . November 28, 2007.
  46. Web site: about_Pipelines. . Microsoft. May 8, 2014.
  47. Web site: about_Objects. . Microsoft. May 8, 2014.
  48. Web site: about_Format.ps1xml. TechNet. Microsoft. May 8, 2014.
  49. Web site: Anonymous Functions and Code Blocks in PowerShell . January 21, 2012.
  50. Web site: Introduction to Windows PowerShell's Variables . November 28, 2007.
  51. Web site: Byte Conversion. Windows PowerShell Tip of the Week. November 15, 2013.
  52. Web site: Converting to size units (KB, MB, GB, TB, and PB) without using PowerShell multipliers. PowerShell Magazine. Ravikanth. May 20, 2013.
  53. Web site: about_Functions. Microsoft TechNet. Microsoft. November 15, 2013. October 17, 2013.
  54. Web site: Lightweight Testing with Windows PowerShell . November 28, 2007.
  55. Web site: Angelopoulos. Alex. Karen. Bemowski. PowerShell Got Smart About Smart Quotes. Windows IT Pro. Penton Media. November 15, 2013. December 4, 2007.
  56. Web site: About Special Characters . June 8, 2017 . Microsoft . Powershell / Scripting . June 20, 2019.
  57. Web site: Trap [Exception] ]. November 28, 2007.
  58. Web site: Running Windows PowerShell Scripts . . November 28, 2007.
  59. Web site: about_Signing. Microsoft TechNet. Microsoft. November 15, 2013. October 17, 2013.
  60. Book: Windows PowerShell Quick Reference. Lee Holmes. O'Reilly Media. September 2006.
  61. Web site: Windows PowerShell Desired State Configuration Overview. eslesar. msdn.microsoft.com. May 23, 2023 .
  62. Web site: It's a Wrap! Windows PowerShell 1.0 Released! . . Windows PowerShell Blog . November 14, 2006 . Leonard . Chung . Jeffrey . Snover . Arul . Kumaravel .
  63. Web site: PowerShell will be installed by default on Windows Server 08 R2 (WS08R2) and Windows 7 (W7)! . Windows PowerShell Blog . . October 28, 2008 . September 27, 2011.
  64. Web site: Windows Management Framework is here! . October 27, 2009 . October 30, 2009.
  65. Web site: Microsoft Support Knowledge Base: Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0) . Support.microsoft.com . September 23, 2011 . September 27, 2011.
  66. Web site: 574 Reasons Why We Are So Proud and Optimistic About W7 and WS08R2 . Windows PowerShell Blog . . October 29, 2008 . September 27, 2011.
  67. Web site: Snover . Jeffrey . PowerShell: Creating Manageable Web Services . 2008 . https://web.archive.org/web/20081013065033/http://channel9.msdn.com/pdc2008/ES24/ . October 13, 2008 . July 19, 2015.
  68. Web site: What's New in CTP of PowerShell 2.0 . November 28, 2007.
  69. Web site: Windows PowerShell V2 Community Technology Preview 2 (CTP2) – releaseNotes . . May 5, 2008 . dead . https://web.archive.org/web/20080506150324/http://www.microsoft.com/downloads/details.aspx?FamilyID=7c8051c2-9bfc-4c81-859d-0864979fa403&DisplayLang=en . May 6, 2008 .
  70. Web site: Differences between PowerShell 1.0 and PowerShell 2.0 . June 26, 2010 . September 17, 2010 . https://web.archive.org/web/20100917075605/http://activexperts.com/admin/powershell/ps1vs2/ . dead .
  71. Web site: Windows PowerShell: Writing Cmdlets in Script . Jones . Don . Microsoft . May 2010 . TechNet Magazine.
  72. Web site: GoGrid Snap-in – Managing Cloud Services with PowerShell . Windows PowerShell Blog . . October 14, 2008 . September 27, 2011.
  73. Web site: Emit-XML . Windows PowerShell Blog . . October 17, 2008 . September 27, 2011.
  74. Web site: Block Comments in V2 . Windows PowerShell Blog . . June 14, 2008 . September 27, 2011.
  75. Web site: PowerShell Version 3 is RTM! . Lee . Thomas . Under The Stairs . August 13, 2012. August 13, 2012.
  76. Web site: Windows Management Framework 3.0. Download Center. Microsoft. November 8, 2012. September 4, 2012.
  77. Web site: Windows Management Framework 3.0 Community Technology Preview (CTP) #2 Available for Download . Windows PowerShell Blog . . December 2, 2011.
  78. Web site: Windows Management Framework 3.0 . Download Center . . December 3, 2012.
  79. Web site: Windows PowerShell System Requirements . Jofre . JuanPablo . Microsoft . December 14, 2016 . Microsoft Developer Network . April 20, 2017.
  80. Book: Honeycutt, Jerry. Introducing Windows 8: An Overview for IT Professionals. 2012. Microsoft Press. Redmond, WA. 978-0-7356-7050-1. Woolley . Valerie.
  81. Web site: Windows Management Framework 4.0 is now available. Microsoft. November 4, 2013. October 24, 2013.
  82. Web site: Levy. Shay. New Features in Windows PowerShell 4.0. PowerShell Magazine. June 26, 2013. June 25, 2013.
  83. Web site: Desired State Configuration in Windows Server 2012 R2 PowerShell. Channel 9. Microsoft. June 26, 2013. June 3, 2013. December 26, 2013. https://web.archive.org/web/20131226224907/http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/MDC-B302#fbid=sBK5uHH2bcL. dead.
  84. Web site: Hall. Adrian. Thoughts from Microsoft TechEd North America. Blogs: Tips & Tricks. Splunk. June 26, 2013. June 7, 2013.
  85. Web site: Windows Management Framework (WMF) 5.0 RTM packages has been republished. Windows PowerShell Blog. Microsoft. February 24, 2016.
  86. Web site: Q and A. GitHub. April 21, 2015.
  87. Web site: Windows Management Framework V5 Preview . blogs.technet.com . . Jeffrey . Snover . April 3, 2014 . April 21, 2015 . https://web.archive.org/web/20140630174828/http://blogs.technet.com/b/windowsserver/archive/2014/04/03/windows-management-framework-v5-preview.aspx . June 30, 2014 . dead .
  88. Web site:
    1. PSTip New PowerShell Commands in Windows 10 Anniversary Update
    . Jaap Brasser. says. August 2, 2016.
  89. Web site: What's New In Windows Server 2016 Standard Edition Part 9 – Management And Automation. September 4, 2016 .
  90. Web site: Microsoft.PowerShell.LocalAccounts Module. technet.microsoft.com. June 16, 2016 .
  91. Web site: Announcing Windows Management Framework (WMF) 5.1 Preview. July 16, 2016.
  92. Web site: WMF 5.1. Microsoft Download Center.
  93. Web site: 2024-03-07 . What is Windows PowerShell? - PowerShell . 2024-08-19 . Microsoft Learn . en-us.
  94. Web site: 2024-04-02 . Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell . 2024-08-19 . Microsoft Learn . en-us.
  95. Web site: Aiello . Joey . PowerShell Core 6.0: Generally Available (GA) and Supported! . PowerShell Team Blog . Microsoft . June 11, 2018 . 1 . https://archive.today/20180611172006/https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/ . June 11, 2018 . January 11, 2018 . live .
  96. Web site: Aiello . Joey . Wheeler . Sean . PowerShell Core Support Lifecycle . Microsoft Docs . . January 10, 2018.
  97. Web site: Calvo. Angel. Top 10 most exciting reasons to migrate. PowerShell AMA. Microsoft. January 11, 2018.
  98. Web site: sdwheeler . 2023-08-03 . What's New in PowerShell Core 6.0 . 2023-12-11 . learn.microsoft.com . en-us . Default encoding is UTF-8 without a BOM except for New-ModuleManifest.
  99. Web site: 2023-11-29 . Understanding file encoding in VS Code and PowerShell - PowerShell . 2023-12-11 . learn.microsoft.com . en-us.
  100. Web site: Announcing PowerShell Core 6.1 . devblogs.microsoft.com . . Joey . Aiello. September 13, 2018 . June 1, 2019.
  101. Web site: PowerShell/PowerShell. June 22, 2020. GitHub. en.
  102. Web site: General Availability of PowerShell Core 6.2 . devblogs.microsoft.com . . Steve . Lee . March 28, 2019 . June 1, 2019.
  103. Web site: Microsoft Releases PowerShell 7 Preview . . Kurt . Mackie. May 30, 2019 . June 1, 2019.
  104. Web site: The Next Release of PowerShell – PowerShell 7 . . Steve . Lee. April 5, 2019 . June 1, 2019.
  105. Web site: PowerShell 7 Road Map . devblogs.microsoft.com . . Steve . Lee. May 30, 2019 . August 12, 2020.
  106. Web site: PowerShell 7 Preview 5 PowerShell . October 23, 2019 . March 5, 2020 . February 15, 2020 . https://web.archive.org/web/20200215113601/https://devblogs.microsoft.com/powershell/powershell-7-preview-5/ . live .
  107. Web site: PowerShell 7.2 is the new version of Microsoft's next-generation shell . itsfoss.net. November 12, 2021.
  108. Web site: Release v7.3.0 Release of PowerShell · PowerShell/PowerShell . . March 7, 2022 . November 9, 2022 . https://web.archive.org/web/20221109021444/https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0 . live .
  109. Web site: Webcmdlets set default charset encoding to UTF8 by CarloToso · Pull Request #18219 · PowerShell/PowerShell . 2023-12-11 . GitHub . en.
  110. Web site: Wheeler . Sean . About Scripts . Microsoft Docs . Microsoft . June 2, 2020.
  111. Web site: Wheeler . Sean . Smatlak . David . Wilson . Chase . How to write a PowerShell module manifest . Docs . Microsoft . October 16, 2019.
  112. Web site: Wheeler . Sean . Smatlak . David . How to Write a PowerShell Script Module . Microsoft Docs . Microsoft . November 22, 2019.
  113. Web site: Wheeler . Sean . How to Write a PowerShell Binary Module . Microsoft Docs . Microsoft . November 13, 2016.
  114. Web site: Wheeler . Sean . Jofre . Juan Pablo . Vorobev . Sergei . Nikolaev . Kirill . Coulter . David . About Types.ps1xml . Microsoft Docs . Microsoft . June 2, 2020.
  115. Web site: Wheeler . Sean . Export-Clixml . Microsoft Docs . Microsoft.
  116. Web site: Wheeler . Sean . Jofre . Juan Pablo . Vorobev . Sergei . Nikolaev . Kirill . Coulter . David . Export-Console . Microsoft Docs . Microsoft.
  117. Web site: Wheeler . Sean . About Session Configuration Files . Microsoft Docs . Microsoft . June 2, 2020.
  118. Web site: Wheeler . Sean . New-PSRoleCapabilityFile . Microsoft Docs . Microsoft . June 2, 2020.
  119. Web site: Microsoft Transporter Suite for Lotus Domino . . March 7, 2008.
  120. Web site: PowerTools for Open XML . June 20, 2008.
  121. Web site: MO74: WebSphere MQ – Windows PowerShell Library . December 5, 2007.
  122. Web site: IoT Core Add-ons command-line options . June 13, 2020.
  123. Web site: PowerShell Commands for Active Directory by Quest Software . July 2, 2008.
  124. Web site: PowerShell Remoting through Group Policy . December 7, 2007.
  125. Web site: VMware vSphere PowerCLI . https://archive.today/20141230022901/https://www.vmware.com/go/PowerCLI . dead . December 30, 2014 . September 9, 2014 .
  126. Web site: IIS7 PowerShell Provider Tech Preview 2 . Windows PowerShell blog . July 3, 2008 . https://web.archive.org/web/20100204104602/https://blogs.msdn.com/powershell/archive/2008/07/03/iis7-powershell-provider-tech-preview-2.aspx . 2010-02-04.
  127. Web site: Kudos to the Win7 Diagnostics Team . June 15, 2009.
  128. Web site: MDT 2010 New Feature #16: PowerShell support. Niehaus . Michael. July 10, 2009. October 27, 2014.
  129. Web site: Kudos to NetApp for Data ONTAP PowerShell ToolKit . June 15, 2010.
  130. Web site: PowerShell Toolkit 4.2 Announcement. June 23, 2016. September 7, 2016.
  131. Web site: Heterogeneous Job Scheduling With PowerShell . September 15, 2010.
  132. Web site: UIAutomation PowerShell Extensions . February 16, 2012 . August 17, 2016 . https://web.archive.org/web/20160817204820/http://uiautomation.codeplex.com/ . dead .
  133. Web site: EqualLogic HIT-ME with PowerShell . March 9, 2012.
  134. [:de:LOGINventory]
  135. Web site: Selenium PowerShell eXtensions . https://archive.today/20130119175212/http://sepsx.codeplex.com/ . dead . January 19, 2013 . August 20, 2012 .
  136. Web site: Pash . . . September 27, 2011.
  137. Web site: Pash Project. GitHub. April 10, 2013.
  138. Web site: Pash is now obsolete · Issue #429 · Pash-Project/Pash. GitHub. en. November 26, 2019.