Summary

Completed

In this module, you learned about functions and modules. Key takeaways:

  • A function is a block of reusable code that you define once and call multiple times, avoiding repeated code in your scripts.

  • Variables have a specific scope — global, script, or function — that limits how they interact with each other.

  • Modules store and share functions across scripts. Functions in modules are discoverable like cmdlets and load automatically when called.

  • Dot sourcing is a method for importing another script into the current scope. If you have a script file that contains functions, you can use dot sourcing to load the functions into memory at a PowerShell prompt.

  • Dot sourcing supports local files and network paths using Universal Naming Convention (UNC) paths.

Additional reading

To learn more, go through the following documents: