New here.. Custom Module with Nested functions..

by Oct 29, 2013

Hello all!

First, I would like to say hello to everyone. I signed up not too long ago but haven't had any time to really post on here. unfortunately, I'm starting off with what's probably an obvious PowerShell Newbie question…

I've been a Software Engineer for 13 years now and am very use to Object Oriented development. I know PowerShell is a scripting language but…this concept completely escapes me. 

let's say I have the following Module:


Function New-Main{
    New-Module -AsCustomObject {
        Function Test1{
            Write-Host $string1  
        Function Test2{
            Write-Host $string2  
        Export-ModuleMember -Function *;

Sorry about the formatting… not sure what happened..

Now, I have a ps1 script where I've imported this module:


Import-Module -Name .NestedFunction.psm1 -Force -Verbose;
$a = New-Main;

is it possible to make this actually show the parameter?

$a = New-Main;
$a.Test1 -string1 "WooHoo!!";

Thanks all!