Chapter 2: Meet PowerShell
Defines the terms needed to distinguish PowerShell versions and understand the difference between a shell and a terminal.
After this chapter you will be able to
- Shell and terminal distinction. Distinguish a shell, which accepts text-based commands, from a terminal, which runs a shell and lets a user interact with it visually.
- Side-by-side PowerShell versions. Explain that PowerShell 7 installs alongside Windows PowerShell 5.1 rather than replacing it, and identify pwsh.exe as PowerShell 7’s process name on Windows.
- Windows installation and launch. Describe the book’s Windows installation route: download the stable PowerShell 7 MSI from the PowerShell GitHub repository, accept the wizard defaults, and then find PowerShell 7 through Windows search.
- Readable console settings. Explain how the suggested console settings make command history and output easier to use and read.
- macOS PowerShell installation. Describe how to prepare for and install PowerShell on macOS using Homebrew and Terminal.
- Linux Installation Example Scope. Explain that PowerShell runs on many Linux distributions, but the book demonstrates installation on Ubuntu 18.04 because it was the latest LTS version when written. Describe where users of other supported distributions can find installation instructions.
- Snap installation on Ubuntu. Describe installing PowerShell on Ubuntu 18.04 with snap, including why installation may prompt for a password and why the command includes --classic.
- Starting PowerShell in Terminal. State how to start PowerShell after installation and where it runs.
- Recommended PowerShell editing setup. Explain why Visual Studio Code with the PowerShell extension is the recommended editing experience for PowerShell.
- Visual Studio Code installation. Describe how to install VS Code on Windows, macOS, or Linux, and how to check that the terminal can open it.
- PowerShell extension installation. Explain how to add the PowerShell extension to VS Code using its marketplace, and identify the terminal-based alternative described here.
- Integrated Console dependence. Explain why the PowerShell Integrated Console should not be killed and how it differs from another terminal running PowerShell.
- Visual Studio Code settings. Describe how to find and change Visual Studio Code settings, including those supplied by the PowerShell extension, and explain what the JSON view shows.
- Color theme selection. Trace how to use the Command Palette to find, preview, and select a color theme in Visual Studio Code.
- Console tab completion. Describe how console tab completion helps enter commands, paths, parameter names, and predefined parameter values. Explain that typing more narrows possible matches.
- Checking the PowerShell version. Apply the section’s version check by running $PSVersionTable and identifying the PSVersion value. State that the exercise calls for at least version 7.1 before continuing.
What it builds on
- Installing PowerShell (chapter 1) · The section refers back to the earlier PowerShell installation steps.
Section by section
Introduction
Defines the terms needed to distinguish PowerShell versions and understand the difference between a shell and a terminal.
- Shell and terminal distinction: Distinguish a shell, which accepts text-based commands, from a terminal, which runs a shell and lets a user interact with it visually.
Why it matters: This distinction makes it easier to understand what you are choosing when you pick a PowerShell interface. - PowerShell version terminology: Distinguish what this chapter means by PowerShell and Windows PowerShell.
Why it matters: The names identify different versions when the chapter discusses PowerShell on Windows.
Key terms: Shell, Terminal, shell agnostic, PowerShell, Windows PowerShell
2.1 PowerShell on Windows
This section shows how to install and launch PowerShell 7 on Windows and configure its console for readable, usable command-line work.
- Side-by-side PowerShell versions: Explain that PowerShell 7 installs alongside Windows PowerShell 5.1 rather than replacing it, and identify pwsh.exe as PowerShell 7’s process name on Windows.
Why it matters: The name helps you tell which PowerShell installation you are using. - Windows installation and launch: Describe the book’s Windows installation route: download the stable PowerShell 7 MSI from the PowerShell GitHub repository, accept the wizard defaults, and then find PowerShell 7 through Windows search.
Why it matters: These steps give you the PowerShell 7 installation used for the book’s exercises. - Console and PowerShell distinction: Distinguish the console application from PowerShell itself, and describe why the console matters on a server without a GUI shell.
Why it matters: Separating the shell from its interface makes it easier to understand why you can work with PowerShell in different applications. - Readable console settings: Explain how the suggested console settings make command history and output easier to use and read.
Why it matters: A readable, correctly sized console helps you spot characters accurately and see the output your commands produce.
Key terms: PowerShell 7, Windows PowerShell (5.1), side-by-side installation, pwsh.exe, powershell.exe, MSI, stable release, PowerShell GitHub repo, PowerShell console application, GUI shell
2.2 PowerShell on macOS
This section introduces the macOS installation instructions and notes that the book uses the default Terminal application.
2.2.1 Installation on macOS
This section shows how to install PowerShell on macOS with Homebrew and start it in Terminal.
- macOS PowerShell installation: Describe how to prepare for and install PowerShell on macOS using Homebrew and Terminal.
Why it matters: These steps get PowerShell onto a Mac before you try to run it. - Starting PowerShell in Terminal: State how to start PowerShell after installing it on macOS.
Why it matters: Installing PowerShell and opening it are separate steps.
Key terms: Homebrew, Terminal, PowerShell, pwsh
2.3 PowerShell on Linux (Ubuntu 18.04)
This section explains why the book uses Ubuntu 18.04 for its Linux installation example and where readers using other supported distributions should look.
- Linux Installation Example Scope: Explain that PowerShell runs on many Linux distributions, but the book demonstrates installation on Ubuntu 18.04 because it was the latest LTS version when written. Describe where users of other supported distributions can find installation instructions.
Why it matters: It helps you choose instructions for your own Linux distribution rather than assuming the Ubuntu example applies everywhere.
Key terms: Linux distributions, Ubuntu 18.04, LTS, PowerShell docs
2.3.1 Installation on Ubuntu 18.04
Shows how to install PowerShell with snap on Ubuntu 18.04 and start it in Terminal.
- Snap installation on Ubuntu: Describe installing PowerShell on Ubuntu 18.04 with snap, including why installation may prompt for a password and why the command includes --classic.
Why it matters: These details explain the password prompt and the --classic option during installation. - Starting PowerShell in Terminal: State how to start PowerShell after installation and where it runs.
Why it matters: Installing PowerShell is only the first step; pwsh opens the interface used to work with it in Terminal.
Key terms: snap, root, --classic, classic snap package, pwsh, Terminal
2.4 Visual Studio Code and the PowerShell extension
The section distinguishes Visual Studio Code from Visual Studio and explains why VS Code with the PowerShell extension is the recommended editor instead of the PowerShell ISE.
- Visual Studio Code distinction: Distinguish Visual Studio Code from Visual Studio as described here.
Why it matters: The similar names should not make you think the book is asking you to use the full Visual Studio IDE. - Recommended PowerShell editing setup: Explain why Visual Studio Code with the PowerShell extension is the recommended editing experience for PowerShell.
Why it matters: The recommendation tells you which editor-and-extension combination the book expects you to use. - PowerShell ISE support status: Describe why the section directs readers toward VS Code with the PowerShell extension rather than the PowerShell ISE.
Why it matters: The ISE's support status explains why the book emphasizes the newer editing setup.
Key terms: Visual Studio, Visual Studio Code, integrated development environment (IDE), PowerShell extension, marketplace, open source, cross-platform, PowerShell ISE, support mode
2.4.1 Installing Visual Studio Code and the PowerShell extension
This subsection shows how to install Visual Studio Code, add its PowerShell extension, and check that the `code` command opens VS Code.
- Visual Studio Code installation: Describe how to install VS Code on Windows, macOS, or Linux, and how to check that the terminal can open it.
Why it matters: Installing VS Code and confirming that it opens gives you the editor needed for the next steps. - PowerShell extension installation: Explain how to add the PowerShell extension to VS Code using its marketplace, and identify the terminal-based alternative described here.
Why it matters: The PowerShell extension is a separate installation step after installing VS Code.
Key terms: Visual Studio Code, VS Code, code command, PowerShell extension, marketplace
2.4.2 Getting familiar with Visual Studio Code
This section orients readers to Visual Studio Code’s PowerShell workspace, especially the Integrated Console and how it differs from an ordinary terminal.
- PowerShell workspace areas: Describe what the Command Explorer, script editor pane, and Integrated Console are for in Visual Studio Code.
Why it matters: Recognizing these areas helps you find the right place to run commands or view scripts. - Integrated Console dependence: Explain why the PowerShell Integrated Console should not be killed and how it differs from another terminal running PowerShell.
Why it matters: Keeping the Integrated Console alive preserves the PowerShell extension’s features. - Console and terminal controls: Describe how to hide and restore the Integrated Console, expand the terminal pane, and open an additional terminal.
Why it matters: These controls let you rearrange the workspace without accidentally destroying the console the extension needs. - Different PowerShell workspaces: Distinguish the intended uses of Visual Studio Code and a Terminal application, and describe how to get PowerShell in an additional Bash terminal.
Why it matters: The two environments serve different purposes, and an extra terminal need not start in PowerShell.
Key terms: Command Explorer, script editor pane, Integrated Console, PowerShell Integrated Console, PowerShell extension, normal terminal, terminal pane, split terminal button, plus sign button, Visual Studio Code
2.4.3 Customizing Visual Studio Code and the PowerShell extension
This section shows how to customize Visual Studio Code and the PowerShell extension through settings and color themes.
- Visual Studio Code settings: Describe how to find and change Visual Studio Code settings, including those supplied by the PowerShell extension, and explain what the JSON view shows.
Why it matters: You can tailor the editor and its PowerShell extension without needing to edit JSON. - Color theme selection: Trace how to use the Command Palette to find, preview, and select a color theme in Visual Studio Code.
Why it matters: The Command Palette gives you a quick way to find the theme action and preview choices.
Key terms: Settings page, PowerShell extension, JSON, Command Palette, Preferences: Color Theme, color theme
2.5 It’s typing class all over again
This section shows how tab completion and IntelliSense reduce typing errors in PowerShell and emphasizes checking commands carefully when errors occur.
- Console tab completion: Describe how console tab completion helps enter commands, paths, parameter names, and predefined parameter values. Explain that typing more narrows possible matches.
Why it matters: Completion helps you enter commands faster while avoiding typos. - Editor IntelliSense suggestions: Explain how IntelliSense in Visual Studio Code with the PowerShell extension compares with console tab completion and how to choose a suggestion.
Why it matters: You can use the same completion ideas while typing in the editor. - Typing accuracy and errors: Explain why precise typing matters in PowerShell and what to check when a command produces errors.
Why it matters: Checking the exact text you entered can reveal a simple cause of failure.
Key terms: tab completion, parameters, enumeration, IntelliSense, Visual Studio Code, PowerShell extension, typos, errors
2.6 What version is this?
This section shows readers how to check their PowerShell version before continuing with the book.
- Checking the PowerShell version: Apply the section’s version check by running $PSVersionTable and identifying the PSVersion value. State that the exercise calls for at least version 7.1 before continuing.
Why it matters: Checking first helps you avoid following the book in an older PowerShell version.
Key terms: $PSVersionTable, PSVersion
2.7 Lab
Where this is used later
- Not programming, more like batch files (chapter 19) · Assumes basic familiarity with VS Code.
- Making commands repeatable (chapter 19) · Writing repeatable commands as scripts draws on the distinction between script editing and quick terminal use.
- The anatomy of a command (chapter 4) · Entering command names and parameters accurately supports running commands.
- Dealing with errors (chapter 4) · Attention to mistyped input helps when dealing with command errors.
Concepts explained in this chapter
- PowerShellPowerShell 3 is the third major version of the PowerShell command-line shell.
- PowerShell extensionThe PowerShell extension is a Visual Studio Code extension that adds PowerShell editing and development support.
- Visual Studio CodeVisual Studio Code is a cross-platform source-code editor with an extensible extension system.
- command-line interfaceA command-line shell is an interactive text-based interface that interprets and runs commands.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
