PowerGUI and Modules

With full PowerShell v2, Windows 7, and Windows Server 2008 R2 support in PowerGUI we obviously absolutely had to fully support Modules – and we do. 🙂 Modules are first class citizens in PowerGUI 1.9: you can add them, get intellisense and F1 help in script editor, start searching for them when adding admin console elements, set them as PowerPack dependencies and so on.

As a quick 101: modules are a new format of PowerShell libraries introduced in PowerShell version 2. Unlike snapins in v1, modules can be scripted – so you do not have to use Visual Studio and compile them.

To create a simple module, just take a PowerShell script file with a function, e.g.:

function Add-Number {
param ($A, $B)

Then create a folder with a name you want for a module (e.g. MATH) and save the file into that folder as MATH.psm1.

To make this module listed as available, put the module folder (in our example MATH) into one of the $env:psmodulepath folders. Which basically means C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ if you want it to be available to anyone, or your Documents\WindowsPowerShell\Modules if it’s for you only.

Now, if in PowerGUI (admin console or script editor) you click File / PowerShell Libraries, you’ll see it listed as one of the options:


As you can see, other modules (BitsTransfer and PSDiagnostics) are also available, as well as v1-style snapins.

You can also use Add Module button, if you want to add a module which you have outside of the default module folders.

Anyways, once you select MATH and click OK, the module becomes available for you. E.g. you get intellisense and F1 help for the module members:


For more information of creating modules of your own, see this MSDN page.

Happy PowerShell v2 scripting! 😉

Tags: , ,


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

My Recent Tweets


The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

August 2009
« Jul   Sep »

%d bloggers like this: