Chapter 9: A practical interlude
Introduces a real-world exercise that applies earlier PowerShell knowledge and models how to work out a solution independently.
After this chapter you will be able to
- YAML in DevOps work. Explain why working with YAML files is a useful PowerShell task: YAML is common in DevOps, and its files have a defined structure, much like CSV or JSON files.
- Command discovery search path. Trace how the search moves from a YAML keyword in help files, to command names, to the online PowerShell Gallery when the first searches return nothing.
- Layered command discovery. Trace the search used to find a YAML command: search local help by keyword, search command names separately, then look in PowerShell Gallery when nothing useful is found locally.
- YAML to JSON conversion. Describe how the example turns a YAML file into JSON, including the intermediate hash table and the purpose of ConvertTo-Json’s Depth parameter.
- Help Examples as Starting Points. Explain why the reader should consult PowerShell help and read its examples when learning a command.
- Safe Experimentation and Persistence. Explain how to learn by trying things in a virtual machine and changing approach when something fails.
What it builds on
- Using help to find commands (chapter 3) · Using help to find commands.
- Extensions: Finding and installing modules (chapter 7) · Finding and installing modules.
- Extensions: Finding and adding modules (chapter 7) · Adding modules to gain commands.
- Connecting one command to another: Less work for you (chapter 6) · Connecting commands with the pipeline
- Finding command examples (chapter 3) · Finding command examples in help.
Section by section
Introduction
Introduces a real-world exercise that applies earlier PowerShell knowledge and models how to work out a solution independently.
9.1 Defining the task
The section introduces YAML as a structured file format common in DevOps and explains why PowerShell users need tools to work with it.
- YAML in DevOps work: Explain why working with YAML files is a useful PowerShell task: YAML is common in DevOps, and its files have a defined structure, much like CSV or JSON files.
Why it matters: This explains why the chapter uses YAML as a practical task.
Key terms: YAML, DevOps, structured file, CSV, JSON
9.2 Finding the commands
This section demonstrates how to find commands for a task by changing search strategies, checking the PowerShell Gallery, and inspecting a newly installed module.
- Command discovery search path: Trace how the search moves from a YAML keyword in help files, to command names, to the online PowerShell Gallery when the first searches return nothing.
Why it matters: A search that returns nothing can still help you decide where to look next. - PowerShell Gallery code caution: Explain why the authors reviewed a module’s code before continuing after installing it from the PowerShell Gallery.
Why it matters: A module’s presence in the Gallery is not, by itself, an assurance about its code. - Newly gained conversion commands: Describe what the authors checked after installing the module and which command names looked useful.
Why it matters: Inspecting a module’s commands connects finding an extension with finding commands you can use.
Key terms: help files, commands, PowerShell Gallery, YAML, module, review the code, ConvertTo, ConvertFrom
9.3 Learning to use the commands
The section shows how to work out an unfamiliar PowerShell task by searching for commands, using the information available about them, and converting a YAML file to JSON.
- Layered command discovery: Trace the search used to find a YAML command: search local help by keyword, search command names separately, then look in PowerShell Gallery when nothing useful is found locally.
Why it matters: This gives you a way to keep looking when the first help search finds nothing. - Help without authored documentation: Explain what PowerShell can show about a command even when its module author supplied no help, and why authors should still include help.
Why it matters: Missing documentation need not stop you from trying a straightforward command, though good module help makes that work easier. - YAML to JSON conversion: Describe how the example turns a YAML file into JSON, including the intermediate hash table and the purpose of ConvertTo-Json’s Depth parameter.
Why it matters: Converting between YAML and JSON lets people use the format their tools or coworkers prefer.
Key terms: local help files, command names, PowerShell Gallery, module, help, syntax, parameters, output, aliases, YAML
9.4 Tips for teaching yourself
This section offers practical habits for learning PowerShell independently: use help, examine what appears on screen, and experiment safely.
- Help Examples as Starting Points: Explain why the reader should consult PowerShell help and read its examples when learning a command.
Why it matters: Help examples give you a starting point when you are teaching yourself a command. - Attention to Screen Information: Describe how to examine information on the screen while figuring out a command.
Why it matters: Careful observation can reveal clues you would miss by looking only for the answer you expected. - Safe Experimentation and Persistence: Explain how to learn by trying things in a virtual machine and changing approach when something fails.
Why it matters: A recoverable place to experiment lets you test questions yourself instead of being stopped by fear of failure.
Key terms: help, examples, help files, information on the screen, virtual machine, snapshot, experimentation
9.5 Lab
9.6 Lab answer
Concepts explained in this chapter
- Get-HelpHelp is a PowerShell command that displays help content for commands and other PowerShell elements.
- help fileA cmdlet help file is a documentation file that describes a PowerShell cmdlet, including its syntax, parameters, and behavior.
- PowerShell GalleryPowerShell Gallery is an online repository for discovering and distributing PowerShell modules, scripts, and related packages.
- commandA command is an executable instruction that a shell can invoke to perform an operation.
- moduleA module is a packaged unit of reusable code and related resources that can be loaded into a software environment.
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.
