O'Reilly logo

Mastering Windows PowerShell Scripting by Brenton J.W. Blawat

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 4. Functions, Switches, and Loops Structures

When you are scripting in PowerShell, you will find that a lot of your coding efforts will require the code to be repeated multiple times in the same script. While repeating the same code may help you accomplish the task, there are many other options for coding more efficient scripts. This chapter explores different techniques for which you can reuse code instead of repeating the same code segments within the same script.

In this chapter, you will learn about the following concepts:

  • Creation of functions
  • Creation of loops
  • Creation of switches
  • Combining the use of functions, switches, and loops
  • Best practices for functions, switches, and loops

Functions

When you need to query or execute code more than ...

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