Powershell – Modules

Powershell is great. but if you really want to do something with an app other than base active directory… you need something more. People write modules to add functionality to Powershell. You can install these and then load them in your code.

Modules are loaded with “Import-Module”

Examples:

Import-Module SMlets

Import-Module ActiveDirectory

Import-Module SQLServer


https://www.powershellgallery.com/packages/SMLets/
https://www.powershellgallery.com/packages/SqlServer/

Note: The AD tools are incorporated in Server 2012 R2 and later.

Of course you are not limited to third party modules – you can also stick all your common functions that you write into a file and call it a PSM1 file. Load it when you need it so that all your scripts don’t need to contain the functions.

les – you can also stick all your common functions that you write into a file and call it a PSM1 file. Load it when you need it so that all your scripts don’t need to contain the functions.

For example, your ” lots of function script” could be saved as FunctionScript.psm1 and then loaded as needed:

Code:

Import-Module ./path/FunctionScript.psm1