O'Reilly logo

PowerShell in Depth: An administrator's guide by Don Jones, Richard Siddaway, and Jeffery Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required