TECHNOLOGY, INTERNET TRENDS, GAMING

These are six Basic PowerShell commands you should know

These are six Basic PowerShell commands you should know

By Valentina Tuta

To be honest, many users find PowerShell intimidating, not only because it is a command-line environment but also because there are thousands of commands available. In fact, the total number of PowerShell commands, or what Microsoft calls cmdlets (pronounced “command-lets”), varies widely depending on the version of Windows you run and how Windows is configured. 

Still, it is not surprising that a Windows implementation supports more than 12,000 PowerShell cmdlets. But don’t worry, you don’t have to learn all these thousands of cmdlets. In fact, if you’re still getting started with PowerShell, it’s probably best to learn the basic commands. However, it’s important to get some context on the whole PowerShell coding thing, so let’s go in order.

What Are the Basic PowerShell Commands?

To begin with, there is no official list of “basic” PowerShell cmdlets. Nevertheless, there are a lot of them that, from the point of view of most experts, are fundamental. In fact, these cmdlets are very frequently used together with others. PowerShell cmdlets that you should know include the following:

  1. Get-Command
  2. Get-Help
  3. Clear-Host
  4. Set-Location
  5. Get-ChildItem
  6. Get-Alias

And today we will observe its operation in detail. Then, pay close attention.

Get-Command

The first and most important cmdlet is Get-Command. When used alone, it usually displays a list of all known PowerShell cmdlets, and usually this list is almost infinite, as it has thousands.

Now, although it doesn’t seem particularly useful, it is necessary for you to know it because it can help you find the cmdlet you need in certain situations.

As you will see, most of the codes we are going to show here are composed of two words: a verb and a noun, separated by a hyphen.

In the case of Get-Command, Get is a verb and Command is a noun. A verb or a noun that is used in one cmdlet is often supported by other cmdlets, as well. The verb Get, for example, is used in a huge number of cmdlets. Get usually instructs the cmdlet to return a list of information (examples: Get-Users, Get-Process, etc.).

If you want to know all the cmdlets that support Get, just type: Get-Command Get-*

Get-Help

Get-Help is another essential. While Get-Command can help you find the name of a specific cmdlet, Get-Help can show you how to use a specific cmdlet. To use it, simply type the command followed by the name of the cmdlet you need help with.

For example, if you want to know how to use Get-Command, you would type this: Get-Help Get-Command

Clear-Host

The Clear-Host cmdlet could be considered one of the easiest to use. In fact, it is used to clear the screen. So if you need to clear the data displayed on your screen, you only need to type “Clear-Host.”

But this is not the only way, because as a shortcut, you can also use the CLS command to clear the screen. CLS is a holdover from the DOS days and is an alias of the Clear-Host cmdlet (you will find more information about aliases in the Get-Alias section below).

Set-Location

This cmdlet is used to navigate through the It can be used as an alternative to the CD command (a remnant of DOS, which stands for Change Directory). You can use it as an alternative to the CD command (a remnant of DOS, which stands for Change Directory). To use Set-Location, you simply add the -Path parameter and then provide the path to go to. Thus, if you wanted to navigate to C:\Users\Brien, you would type this: Set-Location -Path “C:\Users\Brien”

Get-ChildItem

This is another very useful command in PowerShell. You see, when you type the cmdlet Get-ChildItem alone, PowerShell will display the contents of the current folder, and, well, basically, that’s its function.

Get-Alias

Alright, once you become familiar with PowerShell, you will find that some commands don’t adhere to the verb-noun naming convention mentioned above. Such commands are usually aliases.

So, an alias is just an alternative name for a PowerShell cmdlet. In some cases, an alias is simply used as a shortcut. For example, you can type Select instead of Select-Object because the word Select is an alias for Select-Object. 

On the other hand, aliases are also used for backward compatibility purposes. For example, in the days of DOS, the DIR command was used to view files within a folder. The DIR command is still used within the Windows command prompt window. Although PowerShell uses a different command (Get-ChildItem), DIR is used as an alias.

Then, Get-Alias can help you to find out to which 

PowerShell cmdlet that an alias points to For example, to find out which cmdlet was being used when you typed DIR, you could type: Get-Alias DIR. Which will show you that DIR is an alias for Get-ChildItem, and so on.

%d bloggers like this: