PowerShell and Command Prompt on Windows
Before starting, I would like to mention the link for the reference video:
Windows has two command shells: The Command Prompt and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations. Command prompt and windows PowerShell are two similar ideas but PowerShell is more advanced.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets . Cmdlets (🗣Command lets) are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in PowerShell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
PowerShell not only refers to program you run on windows, it actually refers to whole a scripted programming language called PowerShell.
Short explanation:- Command Prompt is extremely limited to getting and running commands, whereas in PowerShell, being a programming language, you can set variables, make functions, carry out operations etc.
Here, the variable is defined in the format: $variable_name = value.
cmdlets are more advanced functions made by Microsoft natively in the PowerShell.
Features of commands in PowerShell:
- PowerShell cmdlets use a consistent
verb-noun
structure, where the verb represents the action and the noun represents the object to operate on. Example: Set-Location - Due to alias between command prompt and PowerShell, pretty much all the old commands in command prompt do the exact thing in PowerShell, if you type
cd
in PowerShell, here it will automatically assign thatcd=Set-Location
and function well. - Imp: A lot of these commands you use in PowerShell might not even be commands at all because a lot of them are not commands but rather programs in the system32 folder in windows. For example: Ping command runs the PING.exe which is in system32 folder, same goes with ipconfig etc.
get-command
gives info about other used commands
get-alias
gives the list of all aliases between command prompt, Linux bash and PowerShell.
- PowerShell uses pipes ( | )to pipe data from one command into the other.
- PowerShell can produce output in form of objects rather than strings.
- Command Prompt is also able to do scripts using batch files but PowerShell uses ps1 files as the script extension.
So, these were some basic differences and the power of PowerShell. For, the table of basic PowerShell commands, you can refer to the following link:
Thank You!