O'Reilly logo

Windows PowerShell 4.0 for .NET Developers by Sherif Talaat

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Windows PowerShell Modules

In this section, we will learn by examples the different types of PowerShell modules and how we can create each type.

The script modules

A script module is simply a PowerShell file with (.psm1), a file extension that contains a PowerShell code such as functions, variables, and aliases.

To create a script module, we will create a couple of simple functions along with an alias for each one; those functions will do addition and subtraction operations for two numbers, and then will save this script in a file with the extension .psm1. The filename will be the module name when you import it.

Function Add-Numbers($x,$y) { $x + $y } Function Subtract-Numbers($x,$y) { $x - $y } New-Alias -Name an -Value Add-Numbers New-Alias ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required