PowerShell
PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a language defined for it. Originally only for Windows, 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 and the latter on.NET.
PowerShell is bundled with current versions of Windows and can be installed on macOS and Linux. Since Windows 10 build 14971, PowerShell replaced Command Prompt as the default command shell exposed by File Explorer.
In PowerShell, administrative tasks are generally performed via cmdlets, 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. 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. Other Microsoft applications including Microsoft SQL Server 2008 also expose their management interface via PowerShell cmdlets.
PowerShell includes its own extensive, console-based help 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
Shell programs, including PowerShell, trace lineage to shells in older operating systems such as MS-DOS and Xenix which exposed system functionality to the user almost exclusively via a command-line interface although 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 the newer cmd.exe a significant upgrade from COMMAND.COM. Both environments provide CLI for both internal and external commands and automation via batch files a relatively primitive language for scripting.To address limitations of these shells including the inability to directly use a software component exposed via COM Microsoft introduced 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. These scripts can use COM components directly, but it has relatively inaccessible documentation and 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 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.
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 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. 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. The ideas behind it were published in August 2002 in a white paper called the "Monad Manifesto" by its chief architect, Jeffrey Snover. 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 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.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, a year and a half 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. Release Candidate 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. PowerShell v2.0 development began before PowerShell v1.0 shipped. During the development, Microsoft shipped three community technology previews. 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. 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".
Windows 10 shipped with Pester, a script validation suite for PowerShell.
On August 18, 2016, Microsoft announced that they had made PowerShell open-source and cross-platform with support for Windows, macOS, CentOS and Ubuntu. The source code was published on GitHub. 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. Starting with version 5.1, PowerShell Core is bundled with Windows Server 2016 Nano Server.
Pash
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. 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, and finally ceased in 2016 when PowerShell was officially made open-source and cross-platform.Design
Philosophy
A key design goal 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 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.Grammar
PowerShell's developers based the core grammar of the tool on that of the POSIX 1003.2 KornShell.However, PowerShell's language was also influenced by PHP, Perl, and many other existing languages.
Named commands
PowerShell can execute four kinds of named commands:- cmdlets
- PowerShell scripts
- PowerShell functions
- Standalone executable programs