PowerShell modules
In the previous chapters, we have used files to package scripts, functions to easily reuse our code, and the modules for each of the Office 365 APIs. As your code gets more complex, the logical progression is to implement your own modules.
Advantages of modules are as follows:
- Package functionality for distribution and reuse
- Provides documentation infrastructure
- Can have private and public functions
We will get started by reviewing the available commands to work with modules.
To showcase the advantages of modules, we will create an example. Our module will support a dashboard in SharePoint Online. The dashboard will display daily sales for each of the products in the database.
So that we do not deviate too much from the scope of this chapter, we will use the AdventureWorks schema (http://msftdbprodsamples.codeplex.com/releases/view/55330). This database contains a simple model of products, customers, and sales that we will use to calculate daily sales.
In this scenario, we calculate...