Learn

Running commands in PowerShell can help us accomplish many different tasks. PowerShell commands are called CmdLets, which is pronounced command-lets. Their names help us understand their action because they are given a “Verb”-“Noun” command format, such as:

Get-Date

The above PowerShell command has the verb Get, and the noun Date, which leads us to believe the current date will be retrieved and printed to the terminal.

In the last exercise, you may have printed “Hello, World!” in the terminal using:

Write-Host "Hello, World!"

This command will write to the host, printing a given argument to the terminal. In this case, the string “Hello, World!” is used as an argument to Write-Host. As we will see in the next exercise and future lessons, Write-Host is used within scripts to create output for the user and display data being processed.

Get-Date and Write-Host are just a couple of the many CmdLets we can run in the PowerShell terminal. To discover more commands available to us, use the following:

Get-Command

Without any argument, Get-Command will output all available CmdLets. We can also request specific CmdLets. To output all Get commands, we need to pass an argument using the -Verb flag:

Get-Command -Verb Get

The -Verb flag looks for any commands whose verb matches the argument given: Get.

We can also look for specific nouns:

Get-Command -Noun Host

This command outputs all the commands acting on Host, the terminal.

Lastly, as with any terminal session, our screen can get filled with a lot of text. To clear the terminal, use the following:

Clear-Host

Run this to clear the terminal session.

Instructions

1.

The exercises in this lesson use the Check Work button with the terminal. Perform the tasks and click the Check Work button to move through the instructions. You can advance to the next task or exercise if you accomplish the task correctly.

Let’s practice a few of the commands you learned.

Start by outputting today’s date.

Click Check Work when complete.

2.

Now output any text you want using Write-Host.

Click Check Work when complete.

3.

Let’s see if any other commands act on the Date.

Output only commands with Date as the noun.

Click Check Work when complete.

4.

Lastly, clean up your terminal session by running a single command.

Click Check Work when complete.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?