Working with Functions in Windows PowerShell

  • 11/11/2015

Chapter 6 quick reference

To

Do this

Create a function

Use the Function keyword, and provide a name and a script block.

Reuse a Windows PowerShell function

Dot-source the fi le containing the function.

Constrain a data type

Use a type constraint in brackets and place it in front of the variable or data to be constrained.

Provide input to a function

Use the Param keyword and supply variables to hold the input.

To use a function

Load the function into memory.

To store a function

Place the function in a script file.

To name a function

Use Get-Verb to identify an appropriate verb, and use the verb-noun naming convention.