Chapter 6. Working with Functions

After completing this chapter, you will be able to:

  • Understand functions.

  • Use functions to encapsulate logic.

  • Use functions to provide ease of modification.

  • Use functions to provide ease of reuse.

There are clear-cut guidelines that can be used to design functions. These guidelines can be used to ensure that functions are easy to understand, easy to maintain, and easy to troubleshoot. This chapter will examine the reasons for the scripting guidelines and provide examples of both good and bad code design.

Understanding functions

In Microsoft Windows PowerShell, functions have moved to the forefront as the primary programming element used when writing Windows PowerShell scripts. This is not necessarily due to improvements ...

Get Windows PowerShell™ 3.0 Step by Step 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.