Ask Learn Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In this module, you learned about functions and modules. The following are the key takeaways:
A function is a block of reusable code. You can use functions to perform repetitive actions within a script rather than putting the same code in the script multiple times.
Variables have a specific scope and are limited in how they interact between scopes. Variable scopes can be global, script, and function.
You can create modules to store functions and share those functions among scripts. After you put your functions into modules, they're discoverable just as cmdlets are. Also, like the modules included with Windows, the modules you create load automatically when a function is required.
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 Windows PowerShell prompt.
Dot sourcing can load from a local file or over the network by using a Universal Naming Convention (UNC) path.
To learn more, go through the following documents:
Having an issue? We can help!
Please sign in to use this experience.
Sign in