This article gives you a brief description of the difference between powershell and cmd. To put it simply,powershell is a superset of cmd, in other words,what cmd can do,Powershell can do it, but powershell can do a lot of extra work that cmd can't.

cmd can do command line interaction with powershell,Batch processing and powershell scripting are also comparable.

I don't know how you understand cmd, but the following is powershell is based on .net, as long as you understand enough.net, you can use her to do anything i want.

windows powershell is a new windows command line shell designed for system administrators. windows powershell includes an interactive prompt and scripting environment,Both can be used independently or in combination.

Unlike most shells that accept and return text, windows powershell is built on the .net framework common language runtime (clr) and the .net framework,It accepts and returns .net framework objects. This radical change in the environment brings new tools and methods for managing and configuring windows.

windows powershell introduces the concept of cmdlets (pronounced "command-let"), a simple single-function command-line tool built into the shell.You can use each cmdlet separately, but they work when you use these simple tools in combination to perform complex tasks.windows powershell includes more than a hundred basic core cmdlets, and you can write your own cmdlets and share them with other users.

Like many shells, windows powershell gives you access to the file system on your computer.In addition, you can access other data stores using the windows powershell provider,Such as registry and digitally signed certificate storage,As easy as accessing the file system.

simply put,powershell is a superset of cmd, in other words,what cmd can do,Powershell can do it, but powershell can do a lot of extra work that cmd can't.

Mainly system management functions, scripting languages ​​and online help are more powerful,You can really use it just as cmd, you can also learn and use it deeper

Advantages of powershell

Did not failOnly unexpected.With powershell, you can even load dlls written in c/c++ and execute the code inside.com will not say.Digression, the question asked differently,I think the biggest difference between powershell and cmd,And the biggest difference from other * nix shells is that powershell's pipe passes .net object instead of raw string, so this opens a magical door,Because all the components of powershell can coexist in harmony,Do n’t have to guess each other,Don't guess the data you fed me is illegal,Don't worry if the parameter format I feed you is correct.Everyone shares a clr, with rich metadata, to explore and explore the world of .net freely.By the way https://chocolatey.org/, apt-get for windows, based on powershell

Why is powershell powerful

Microsoft is a very "low-key" company, named Microsoft,It feels like "Microsoft going down", this is a joke.windows operating system and office software,So excellentMicrosoft did not dare to name poweros and poweroffice, but in the second year (2006) after the release of monad (the predecessor of powershell), Microsoft directly released windows powershell 1.0, and named it "powershell", this also A little too calm.

Today I will briefly summarize why powershell is so powerful based on my own experience.

Unparalleled convenience

Such as gb, mb, kb units in storage calculations;1..n in array declarations and subscripts of -1;and what you see is what you get,Easy to understand verb + noun structure cmdlet.


Compared to process-oriented,Object-oriented is more convenient and easier to describe the real world,It's also catching up with fashion.

Tie the big tree of .net

As the so-called under the tree is so cool,powershell tied .net this big money,With the powerful class library of the .net framework platform,Almost everything is possible.

Strong compatibility

Fully compatible with other calls on the windows platform,Such as executable files (exe), batch bat and vb script.

Platform-based scalability

Microsoft has an advantage,Compared to the application,It prefers to do platforms.powershell has long been a platform,In the second year after powershell was released,Microsoft's system center operations manager and sharepoint provide components for the platform,Later Active Directory,Not to mention hyper-v, windows azure, office 365.Except for Microsoft,Amazon's cloud platform management,dell's out-of-hand management also provides powershell-based management components.powershell has suddenly become a standard,Became a norm.


If you've heard of powershell for the first time and would like to wait and see,Consider the following 10 examples.

[Mathematical calculation] (39 + 79-51) * 497/28 =?

No matter how fast your mental calculations are,There should be no hitting the Enter key.

ps>(39 + 79-51) * 497/28

[Date] How many minutes are there for the next Valentine's Day?

I know how many days are far away,What if it becomes minutes?

$day=[datetime] "2-14"
if ($now -lt $day) {
$day.subtract ($now) .totalminutes
else {
$day.addyears (1) .subtract ($now) .totalminutes

[Capacity] 3gb>3145726kb??

ps>3gb -gt 3145726kb

[id] Can you generate a guid?

ps>[guid] ::newguid ()

[File] What is the size of all executable files in the windows directory?

dir $env:windir -filter * .exe | measure -sum length

[Registry] What is the value of "enable64bit" in the registry path hkey_local_machine \ software \ microsoft \ .netframework?

(get-itemproperty -path hklm:software \ microsoft \ .netframework) .enable64bit

[Certificate] Is the certificate with fingerprint [28de15612aff1cd69596ab17af06ae86cb9c003b] in the certificate storage area?

ls cert:\ localmachine \ my \ |
where {$_. thumbprint -eq "28de15612aff1cd69596ab17af06ae86cb9c003b"}

[Service] Is the printer service started?

get-service spooler

[Process] How many ie processes are currently running?

(get-process iexplore) .count

[Report] Export all running process information as html report?

get-process | convertto-html | out-file a.html

Now that you know the power of powershell,Powershell is quite easy to use on windows platform.

  • Previous Analysis of CheckBox and RadioButton usage examples for Android controls
  • Next Summary of pointer to data types and operations in C ++