liveBook · Manning

Chapter 22: Using someone else’s script

What you will learn in chapter 22 of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

This introduction explains why understanding and reusing other people’s PowerShell scripts matters, even when those scripts are imperfect or contain unfamiliar features.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why understanding and reusing other people’s PowerShell scripts matters, even when those scripts are imperfect or contain unfamiliar features.

Key terms: PowerShell script, advanced PowerShell features

22.1 The script

Introduces a real-world script found online and states the environment it needs to run, while noting that readers can study it without that environment.

Key terms: Get-AdExistence.ps1, Microsoft’s AD cmdlets, Windows-based computer, Active Directory

22.1.1 Parameter block

Identifies what the script’s parameter block requires and gives a basic orientation to its process block.

Key terms: parameter block, -Computers, array, mandatory, process block

22.1.2 Process block

This subsection explains how the script checks Active Directory, collects computer information, and outputs it, while briefly introducing Try/Catch.

Key terms: $comp, $properties, hash table, PS custom object, Write-Output, Try, Catch

22.2 It’s a line-by-line examination

This section gives a practical method for understanding someone else’s PowerShell script line by line so you can adapt it to your needs.

Key terms: variables, command parameters, Get- commands, help, virtual machine, wildcards

22.3 Lab

22.4 Lab answer

Where this is used later

Concepts explained in this chapter

← Chapter 21: Using regular expressions to parse text files Chapter 23: Adding logic and loops →

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.