Posts

Showing posts from April, 2018

PowerShell modules

Overview of PowerShell Modules A module in PowerShell is basically a script with exposed members, such as Functions and Variables. It's best for a specific module to serve a singular purpose. There are four kinds of PowerShell module. (As documented in this Microsoft link:  click here .) Script Modules -- PSM1 files that usually contain functions, but can contain any valid PowerShell code. Binary Modules -- Compiled DLL files, which can be created in .NET languages like C#, F# or VB. Manifest Modules -- These are Script Modules which contain a manifest. Dynamic Modules -- In memory modules which haven't been persisted to permanent storage. How To Create A PowerShell Module At the basic level, a PowerShell module is a text file with a ".psm1" extension. Here's an example: # A private variable. $prefix = 'Some text' Function Get-Prefix {     $prefix } Function Append-Prefix ($suffix) {     $prefix + $suffix } Function Hidden...