5 PowerShell Commands You Need to Know

5 PowerShell Commands You Need to Know

PowerShell is a task automation solution comprising a command-line shell, a scripting language, and more. It runs on Windows, Linux, and macOS. Let's look at some essential PowerShell commands you can use daily.

Get-Help

Get-Help helps you find necessary information for commands, scripts, and more. To see a small manual for a PowerShell command, you need to type Get-Help then the process you are asking guidance for.

For example, you can type in Get-Help Get-Content to view the different options for the Get-Content command:

Typing in Get-Help Get-Content -online will open a browser to Microsoft's blog on the Get-Content command.

Get-Process

If you're familiar with Windows Task Manager, the Get-Process command is similar.

Typing the Get-Process command will show an active list of everything running.

If you want to display processes that begin with the letter "f", use the * wildcard: Get-Process f*. If you're a specific set of apps with similar names, you can type it in like so:

Get-Process *sql*

Get-Process can be sorted in multiple ways, alphabetically, CPU usage, and more. You can also add more information that isn't included with the "f1" command:

Get-Process edge, explorer | f1 Name, FileVersion


Start-Process

The Start-Process command can start one or more apps on your computer. For example:

Start-Process notepad

Say you wanted to run this as administrator. You can add parameters to make it specific:

Start-Process -FilePath "notepad" -Verb runAs

Stop-Process

If you figure out what process is slowing down your computer, you can stop it with PowerShell commands. You can identify it by Name, Process ID (PID), and more. For example, let's shut down Notepad.

Stop-Process -Name "notepad"

This will stop all instances of NotePad from running. If you want to be thorough, add the -Confirm and -PassThru switches. PowerShell will prompt you to confirm, and then show confirmation NotePad is stopped.

Stop-Process -Name "notepad" -Confirm -PassThru


Get-History

When you become a PowerShell Wizard, there will be a lot of commands you end up running. You can press the up or down arrow keys to find previous commands. Or, you can list them all with PowerShell commands.

Get-History will show all recently executed commands and their ID. You can add more context to this. Get-History Id | f1 will show more info.

The command Invoke-History Id will rerun commands with the corresponding ID.

Wrapping Up

Use the Get-Help command for instructions on specific commands.

Get-Process will show you an active list of all applications running on your machine. Start-Process can open any app by name or PID.

Is there an app slowing your computer down? Use Stop-Process to kill it.

And if you lose track of what commands you're running, the Get-History command will display a list.

Stay up to date with the latest tech and cybersecurity news!

Back to blog