|
| 1 | +--- |
| 2 | +title: "Smoother and closer touch by Powershell" |
| 3 | +tags: [windows, cross-platform, powershell] |
| 4 | +category: "powershell" |
| 5 | +comment: true |
| 6 | +--- |
| 7 | + |
| 8 | +### Background |
| 9 | + |
| 10 | +After Microsoft told the world about the desire to Linux, Windows Powershell became shared to the world like Linux did, |
| 11 | + |
| 12 | +also supported cross-platform since 2016, which is the task automation and configuration management framework, |
| 13 | + |
| 14 | +with unique command-line shell and scripting language. There are some classic shells still widely used in Linux. |
| 15 | + |
| 16 | +Some of the Linux or open-source fans may laugh at what Windows try to compact with Linux and even MacOS. |
| 17 | + |
| 18 | +However, [Powershell][ms-powershell] is further improvement version from history with modern IT view by many intelligent experts, |
| 19 | + |
| 20 | +actually for some admin tasks it always can give much sharper solutions than the old-school [UNIX shells][unix-shells]. |
| 21 | + |
| 22 | +### Design |
| 23 | + |
| 24 | +From official, Windows PowerShell can execute four kinds of named commands: |
| 25 | + |
| 26 | +- **cmdlets**: <br>command-lets are .NET programs followed *Verb*-*Noun* naming pattern, receive/emit objects through pipeline |
| 27 | +- **PowerShell scripts**: <br>chain of commands to execute which pipeline objects can be passed, secured by execution policy |
| 28 | +- **PowerShell functions**: <br>a grouping of code that handle input and return output, advanced functions can create "*script cmdlets*" |
| 29 | +- **Standalone executable programs**: <br>launches it in a separate process, as usual as the standard way |
| 30 | + |
| 31 | +### Benefits |
| 32 | + |
| 33 | +1. **Cross-platform**: <br>general set of commands which are fitted for both Windows, Linux, MacOS, that one shell is needed to learn only |
| 34 | +2. **Structured-object data**: <br>optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models |
| 35 | +3. **Humanized language**: <br>comprehensible cmdlets and syntax closed to human thinking and logic, powerful auto-completion with help |
| 36 | + |
| 37 | +There is no doubt that the new Powershell is a time evolution shell interface for human to talk with computer. |
| 38 | + |
| 39 | +However, it still needs time to develop and grow up to become an universal IT standard in real, it made a good start! |
| 40 | + |
| 41 | +### Syntax |
| 42 | + |
| 43 | +The common use of powershell is shown below. |
| 44 | + |
| 45 | +The image may be small to display, then drag the image to new tab to lookup. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +[ms-powershell]: https://docs.microsoft.com/en-us/powershell/ |
| 50 | +[unix-shells]: https://en.wikipedia.org/wiki/Unix_shell |
0 commit comments