PowerShell mastery: cmdlet

You might have already come across PowerShell’s cmdlet. If you want to master using this shell of Windows, you might be wondering what is it that makes cmdlet so powerful. This article will break it down for you and help you to make the most of the command line of your Windows system.

What is exactly cmdlet?

Cmdlet, pronounced as “command-lets” are a bunch of PowerShell commands that come in native with PowerShell and not a stand-alone executables at all. As we know by now that PowerShell has modules, this where all of the cmdlets are stored. These cmdlets can be loaded right on demand. One of the best thing about cmdlets is that you can write your own cmdlets with any .NET language or within the PowerShell Script itself.

Native cmdlets

While you are getting familiar with the PowerShell, feel free to get familiar with the various of native cmdlets.

You will notice one of the most common command pattern in PowerShell which is, a verb-noun kind of pair for every cmdlets.

For instance, Get-command. This command gives you the list of all of the Cmdlets registered inside the command shell. This verb-noun naming convention helps you to stay on track with various command pattern. Verb part apparently defines the action part and the noun part defines the resources where the action part is applicable or will take an effect.

A little teaser of the PowerShell, you have two commands. Such as – dir and Get-childItem. Fundamentally, they both do the same thing, such as find something or list the content of the directory. Yet where the line divides this two command is, Get-childItem has more features or switches that are added on top of the general dir.

For instance, if we are to search in a directory all of the png files, we would run something like dir *.png  This basically tells the system that, find all of the png files in the folder with the Get-childItem, if we run this command Get-ChildItem .-Include *.png -Recurse –Force.

This will scrutinize thorough not only png files but any other format as well like – PowerPoint, Word, Acrobat etc.

Structure of the command

In case, you are wondering about these commands, let’s break them down. The first one is obviously the command itself then dot indicates the current directory, include tells the command to get all the file type following the include word, which is *.png in our case. -recurse is the way of telling to drill into every sub directory and with the -force we are telling it to get every hidden files as well as system files.

As you can see, this was just a scoop of the power of the PowerShell usage. Along the way, as you learn to utilize this tool, you are becoming invincible in the field of computer.