Skip to content
Archive of entries posted on February 2012

Importing Modules using -AsCustomObject

I recently got thinking about the -AsCustomObject switch for the Import-Module cmdlet. I have seen it several times in discussions of implementing “classes” in PowerShell. Here’s a typical (i.e. trivial) example: #module adder.psm1 function add-numbers($x,$y){ return $x+$y } With that module, we can do the standard module stuff: PS> import-module adder PS> add-numbers 1 2 [...]

Share