Chapter 7. Functions and scripts

7.1

Function basics

178

7.2

Formal parameters and the param statement

181

7.3

Returning values from functions

193

7.4

Using functions in a pipeline

199

7.5

Managing functions

204

7.6

Scripts at long last

205

7.7

Summary

212

 

And now for something completely different...

 
 --Monty Python
 

Porcupine quills. We’ve always done it with porcupine quills

 
 --Dilbert

Seven chapters in and no scripts? Okay—fine—here you go:

"Hello, world"

As you will have astutely observed from the title, in this chapter we finally get into writing PowerShell scripts in all their myriad forms. As mentioned in chapter 2, functions and scripts are two of the four types of PowerShell commands (the others are cmdlets and external commands). Prior programming experience ...

Get Windows PowerShell in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.