Compartmentalize with Modules

A Windows PowerShell module is a self-contained, reusable package of variables, functions, scripts, cmdlets, providers, aliases, and much more. Code within a module executes in its own scope and does not affect resources declared outside that scope. With modules, it's possible to expose items selectively within the module to outer scopes, thus facilitating the concept of private members.

There are four types of modules that can be created to package and deploy Windows PowerShell capabilities:

Script modules Script modules are created by simply renaming a Windows PowerShell script file so that it has a .psm1 extension. Use the Export-ModuleMember cmdlet to expose functions and variables outside of the module.

Binary ...

Get Automating Microsoft® SharePoint® 2010 Administration with Windows PowerShell® 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.