PowerShell Basics Level: Beginner Chapter 2: Your First PowerShell Commands

Work environments: ISE, console, and VS Code

You can run PowerShell in a console, in the older ISE editor, or in Visual Studio Code. All three run the same language, but they suit different jobs.

Lesson 3 of 5 in Chapter 2: Your First PowerShell Commands. Previous step in this path: PowerShell versions. 3 learning objectives, 6 examples, and a knowledge check.

Start: what you will learn

You can run PowerShell in a console, in the older ISE editor, or in Visual Studio Code. All three run the same language, but they suit different jobs.

Learning objectives

  • Pick the right environment for a quick command and for a script
  • Explain what the ISE and VS Code add over a plain console
  • Open a console and run a safe read only command

Concept in simple words

What it is: A work environment is the place where you type and run PowerShell, and the three common choices are the console, which is a simple text window, the older ISE editor, and Visual Studio Code, which is a modern code editor with a PowerShell extension. A console is also called a terminal window. An extension is an add on that gives an editor extra skills for one language, in this case PowerShell.

Why it works

Why it exists: People use PowerShell for two very different jobs. One job is a quick question, such as what time is it, or which services are running. The other job is a longer script that you want to keep, fix, and run again. One tool is not best for both jobs, so different environments grew up around the same language.

What problem each one solves: The console solves speed. You open it, type one command, and see the answer at once. Visual Studio Code solves care for longer work. It helps you write, save, find mistakes, and test a script step by step. The ISE solved the same editor problem in an older time, for Windows PowerShell only, and that history matters when you meet it in old guides.

Why it works this way: All three run the same PowerShell language, but they are built for different jobs. A console is fast for one quick command, an editor helps you write, save, and fix a longer script, and a good editor also suggests names and shows mistakes as you type. The language does not change when you change the window. What changes is how much help you get while you type, and how easy it is to keep your work.

Think of it like this

Think of it like this: The console is like a notepad for a quick note, and Visual Studio Code is like a desk with drawers, a lamp, and a spell checker for a longer letter. You can write a letter on a notepad, but the desk makes the longer job much easier, and the quick note does not need the desk.

A second analogy that helps: Think of a calculator and a spreadsheet. A calculator is perfect for one sum. A spreadsheet is better when the sum is part of a larger sheet you will reuse and check again. The console is the calculator here. Visual Studio Code is the spreadsheet. Neither is wrong, but each fits a different size of job.

The console, in depth: The console is a text window with a prompt, which is the short mark that shows PowerShell is ready for your next command. You type a command, press Enter, and the result appears below it. There is no file to save, and no project to open. That simplicity is its strength for quick checks, and its weakness for long work, because a long command typed in the console is hard to edit, hard to save, and easy to lose when you close the window.

Visual Studio Code, in depth: Visual Studio Code is a code editor, not a shell by itself. With the PowerShell extension installed, it understands PowerShell: it colours commands, suggests command and parameter names as you type, and helps you run and debug a script. Debugging means running a script in a controlled way, stopping at a line, and looking at what is happening, so you can find a mistake. It also has an integrated terminal, which is a console built into the editor, so you can write a script and run it without switching windows.

The ISE, in depth, and why you should know its limits: The Windows PowerShell Integrated Scripting Environment, called the ISE, was the older official editor for Windows PowerShell. It has an editor pane and a console pane in one window, which was a big help in its time. But it is no longer in active feature development, and it has no support for PowerShell 6 and later. In plain words, it only works with Windows PowerShell 5.1 and earlier. If you open PowerShell 7 work in the ISE, you are using the wrong tool for that edition, and some things will simply not work as expected.

How it works, step by step

How it works, step by step: First, decide how long the job is. For a quick check, open the console, type one command, and press Enter. For a script, open Visual Studio Code, create a file ending in .ps1, which marks it as a PowerShell script, and type your commands there. The .ps1 ending is important, because it tells the editor and PowerShell that the file holds PowerShell commands.

How it works, step by step, continued: Next, save the script file, then run it from the console or from inside Visual Studio Code. If it does not work, read the error message, fix the line in the editor, save again, and run it again. That small loop, write, save, run, fix, is how most scripts grow. Do not skip the save step. An unsaved file in the editor is not the file that runs, so a fix you did not save will not change the result.

Let us walk through an example: In Write-Output "Hello, PowerShell", Write-Output is a command that sends text as output, and the quoted text is the value it sends. In the console, you see the result at once. In a script file, the same line runs when you run the whole file, which is why a script is just saved commands, run in order.

Walkthrough, what changes if you change one part: If you change the quoted text, only the displayed text changes, because that text is the value being sent. If you add a second Write-Output line below the first, the script shows two lines, in order, because a script runs top to bottom. If you remove the quotes, PowerShell will try to read the words as something else, and you will get an error or a different result, so keep text values in quotes.

Let us walk through a second example: In Get-Service | Where-Object { $_.Status -eq "Running" }, Get-Service lists services, and Where-Object keeps only the ones that pass a test. Inside the braces, $_ means the current object being tested, .Status reads its status fact, -eq means equals, and "Running" is the value to match. You will learn each part in later chapters, so for now, read it as a whole sentence: keep only the services whose status equals Running. In the console, this is a fine quick check. In a script, the same line can be one step in a larger job.

Walkthrough, what to look for in the output: Look for the column headings Status and Name, and for rows that all show Running. If a row showed Stopped, the filter would have failed, because only Running services should pass the test. If you see no rows at all, do not assume the command is broken. It may mean no service matched on that computer at that moment, so check the headings and try Get-Service on its own to see the full list.

A safe habit for scripts: Write a script that only reads information first, and run that version before you add any step that changes something. Save the file, run it, and read the output. Only then decide whether a changing step belongs in it. And if PowerShell refuses to run a script file and shows a message about execution policy or a blocked file, stop and read that message. Do not copy a bypass command from a search result to force it through, because that bypass hides the very protection that is asking you to check the file first.

When to use it

When to use it, and when not to: Use the console for quick, read only checks, such as listing services or checking the date. Use Visual Studio Code for scripts you want to keep, share, or run again. Do not use the ISE for PowerShell 7 work, because the ISE only supports Windows PowerShell 5.1, and it is no longer developed.

Common edge cases to expect: First, Visual Studio Code without the PowerShell extension is just a text editor. It will still hold your .ps1 file, but it will not give you PowerShell suggestions or debugging help, so check that the extension is installed. Second, a script run from the wrong folder can fail to find a file it needs, because it looks in the current folder. Third, the integrated terminal in Visual Studio Code may be running a different edition from the console you used earlier, so check $PSVersionTable in the terminal you are actually using.

Worked examples

Read each example in order. Each one explains its parts, then shows what to look for in the output.

Example 1

A quick console check: only running services. You will learn each part in Chapters 2 and 3.

Example 1
Get-Service | Where-Object { $_.Status -eq "Running" }

Illustrative output: Status Name ------ ---- Running Spooler

Example 2

A script file is just text with a .ps1 ending. VS Code helps you write and debug it.

Example 2
# Save this in VS Code as first.ps1, then run it
Write-Output "Hello, PowerShell"

Illustrative output: Hello, PowerShell

Example 3

This is a good first console check. It needs no file, no editor, and no setup, you just type it and press Enter. If you see the current date and time, your console works, and you are ready to try the next command.

Example 3
Get-Date

Illustrative output: Monday, 3 November 2026 10:00:00

Example 4

The same line, run directly in the console instead of from a file. Look for exactly the quoted text in the output. If you see it, your console works, and you have proved that one line behaves the same in the console and in a script, only the place you typed it differs.

Example 4
Write-Output "Hello, PowerShell"

Illustrative output: Hello, PowerShell

Example 5

A script runs top to bottom, one line after another. Look for Step 1 first, then Step 2, in that order. If you swap the two lines and run it again, the output order swaps too, which proves that order in the file is order in the run.

Example 5
# Save this in VS Code as first-two-lines.ps1, then run it
Write-Output "Step 1"
Write-Output "Step 2"

Illustrative output: Step 1 Step 2

Example 6

A console check that shows only two facts per service. Compare it with Get-Service on its own: the services are the same, but the columns shrink to Name and Status. This is a good example of a read only check that needs no editor at all.

Example 6
Get-Service | Select-Object Name, Status

Illustrative output: Name Status ---- ------ Spooler Running

Nothing on this page executes PowerShell code. The outputs above are illustrative only.

Common mistakes and troubleshooting

Read these before you try the examples, so you can spot the same problems in your own work.

  • Writing a long script directly in the console, where a mistake is hard to fix. Use an editor for scripts.
  • Using the ISE for PowerShell 7 work. The ISE only supports Windows PowerShell 5.1.
  • Opening Visual Studio Code for every tiny one line check, or writing a long script in the console where a typo is hard to find and fix.
  • Forgetting to save in the editor before you run. The run uses the saved file, so an unsaved fix changes nothing, and you will chase a mistake you already fixed.
  • Assuming Visual Studio Code alone gives PowerShell help. Without the PowerShell extension installed, you get a plain text editor, not suggestions or debugging.
  • Copying a bypass command to force a blocked script to run, instead of reading the message and checking the file first. A block is a warning to pause, not a puzzle to go around.

Knowledge check

Knowledge check

Which environment is the modern choice for writing longer scripts?

Pick one answer. Feedback appears right away, and you can try again.

Remember this and next step

Remember this: The console is best for a quick check, Visual Studio Code is best for scripts, and the ISE is an older tool that only works with Windows PowerShell 5.1. Pick the tool by the size of the job, save before you run, and read the error before you fix.

Next step: Syntax: Verb-Noun and parameters