PowerShell Introduction
In most people's minds, Windows command-line tools are either from an older eracmd, or the kind that makes you tear your hair out with "clicking around in a GUI".PowerShell。
PowerShell is a cross-platform (Windows / Linux / macOS) automation and configuration management framework introduced by Microsoft, consisting of two parts: a "command-line shell (host)" and a "scripting language".
PowerShell is based on .NET (full .NET Framework or .NET Core / .NET 6+), so it can directly call thousands of .NET APIs and natively supports object-oriented pipeline (object pipeline), rather than the plain-text streams of traditional Shells.
PowerShell is built on the .NET Framework and is designed for system administrators and advanced users to automate various system administration tasks.
Core Features of PowerShell
- Object-oriented: Unlike traditional command-line tools that process text, PowerShell directly handles .NET objects.
- Powerful pipeline: You can easily pass the output of one command to another command.
- Extensibility: You can create custom cmdlets (commands) and modules.
- Cross-platform support: PowerShell Core can run on Windows, Linux, and macOS.
Development History
On UNIX systems, shell programs like bash, sh, and csh have long been trusted assistants for system administrators. Windows had been lacking in this area until PowerShell came along, finally filling that gap. It can not only execute commands like a UNIX shell, but also integrates a scripting language and various auxiliary tools, taking automation capabilities to a higher level.
| Year | Version | Key Milestones |
|---|---|---|
| 2006 | PowerShell 1.0 | Launched with Windows Vista, first debut. |
| 2009 | PowerShell 2.0 | Introduced Remoting (remote control), module support, background tasks. |
| 2012 | PowerShell 3.0 | Added features such as Workflow, scheduled tasks, CIM, etc. |
| 2016 | PowerShell 5.1 | Built into Windows 10, the last generation based on .NET Framework. |
| 2018 | PowerShell Core 6.0 | Officially open-sourced, fully cross-platform, migrated to GitHub. |
| 2020 | PowerShell 7.0 | Based on .NET Core 3.1, first to support coexistence with Windows PowerShell. |
| 2023 | PowerShell 7.4 | Based on .NET 8, performance and compatibility continue to improve, supports native container scenarios. |
Comparison Between PowerShell and Traditional Command Lines
| Comparison item | PowerShell | Traditional command line (Bash / CMD) |
|---|---|---|
| Data type | Object (.NET object) | String / Text |
| Pipeline transmission | Passes objects | Passes text |
| Command style | Verb-noun (e.g.Get-Process) |
Short command (e.g.ps、ls) |
| Scripting capability | Full programming language (supports functions, classes, exceptions) | Simple script syntax |
| Error handling | try-catchException mechanism |
Based on exit codes$?、$LASTEXITCODE |
| Module system | Native support, supports version control and automatic loading | Relies on external commands or source import |
| Remote execution | Built-in Remoting, SSH | Bash relies on ssh, expect, etc., CMD does not support |
| Resource access | Supports multiple providers (registry, variables, certificates, etc.) | Mainly operates on the file system |
| Cross-platform | Yes (PowerShell Core / 7+) | Bash yes, CMD no |
| Extensibility | Can call .NET / custom cmdlets | Relies on third-party command-line tools |
| Output processing | Structured object processing, pipeline chain operations | Plain text requires usinggrep / awketc. for parsing |
Who Should Learn?
- System administrators: batch server management, automated deployment, configuration control
- Developers: build DevOps pipelines, script tools, testing toolchains
- Data analysts: automatically process logs, extract data, system integration
- Beginners: learn command-line programming, understand underlying operating system mechanisms
PowerShell is not just a command-line tool; it is more like an advanced automation platform. Whether you are an operations engineer, a developer, or an ordinary user who wants to master Windows systems, PowerShell is worth understanding and mastering in depth.
It is more flexible than cmd, more powerful than bash, and most importantly—it is becoming the automation infrastructure tool of the new era with a cross-platform stance.
Other extensions