Windows PowerShell provides a set of commands and these are called “cmdlets” or “Command lets“. These are lightweight and run by PowerShell runtime from the command line or from windows PowerShell API. Cmdlets are based on .NET classes and use .NET objects. Thus, cmdlets can receive objects as input and deliver objects as output, which can then feed the input of subsequent objects, enabling cmdlets to form a command pipeline.
Most cmdlets support the use of parameters as part of the input. Parameters can be added to the cmdlet at the command line or passed to cmdlets through the pipeline as the output from a previous cmdlet.
These cmdlets are used in automation script collectively to perform any action on the server. The CMD commands and cmdlets are two different things.
For example, if we need to change the current directory from one to another so in that case, we use the “cd” command and the “Set-Location” cmdlet is the replacement of the cd command in PowerShell.
Syntax: Set-Location “<Path>”
Example: Set-Location “C:\test\New folder”
For this particular example, “cd” or change directory, the command is super popular but PowerShell cmdlet is extremely powerful to perform the different day-to-day administrative operations.
How to get all PowerShell cmdlets
To check all available PowerShell cmdlets execute the below Get-Command cmdlet from the PowerShell command line.
Get-Command -commandtype cmdlet
How to get help for PowerShell cmdlet
To explore help for PowerShell cmdlet execute the below Get-help cmdlet from PowerShell command line.
There are two types of help for the cmdlet local and online. If we did not add the “-online” parameter to “Get-Help” cmdlet it searches for local help else if we added the “-online” parameter to any cmdlet it searches the Microsoft online Library for the desired cmdlet.
Get-Help <Cmdlet-name> -online
Powershell provides hundreds of cmdlets which can be used to perform daily day to day system administrator tasks below is the list of some popular cmdlet.
|Write something on the console.
|Get the current directory physical location.
|Read the content of the specified file.
|List items in a directory.
|Get more information about a specific cmdlet that can be local or online.
|Terminate a running PowerShell process.
|Change the current directory path.
|Remove a file or directory.
|Move a file from one location to another.
|Rename a file.
|Create a new empty file or directory.
|Shut down a local or remote computer.
|Restart a local or remote computer.
|Join a computer to a domain.
Apart from the above, there are many important cmdlets kindly check the complete list by above “Get-Command” cmdlet.
Difference between Command Line(CMD) & PowerShell Cmdlet
|Only Interpret Batch command.
|Execute both Batches as well as PowerShell commands.
|Not Support Intellisense.
|Default window operation system commands.
|Cmdlets are instances of .NET classes
|Only return the output in text.
|It returns the output in the text as well as the collection of objects.
|It Handled by PowerShell Runtime of executing, parsing, and debugging of the script.
|It handled by windows OS.
|Execute as standalone commands.
|Execute as standalone as well as in long automation scripts.
This is the basic overview of cmdlets as a developer or a system administrator you do not need to learn each cmdlet only just need to focus on day-to-day tasks, which can be automated using these cmdlets.