Chapter 20. Basic scripts and functions

This chapter covers

  • Scripting execution scopes
  • Parameterizing your script
  • Outputting scripts
  • Filtering scripts
  • Converting a script to a function

You can accomplish many tasks in PowerShell by typing a command and pressing Enter in the shell console. We expect that most IT pros will start using PowerShell this way and will continue to do so most of the time. Eventually, you’ll probably get tired of typing the same thing over and over and want to make it more easily repeatable. Or you hand off a task to someone else and need to make sure that it’s done exactly as planned. That’s where scripts come in—and it’s also where functions come in.

20.1. Script or function?

Suppose you have some task, perhaps ...

Get PowerShell in Depth now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.