I want do create a custom object with a method that takes more than one parameter. I already managed to add a method that takes one parameter, and it seems to work:
function createMyObject () {
$instance = @{}
add-member -in $instance scriptmethod Foo {
param( [string]$bar = "default" )
echo "in Foo( $bar )"
}
$instance
}
$myObject = createMyObject
But every time I try to add a method with takes two parameters by simply adding another [string]$secondParam
- clause to the param-section of the method, the invocation
$myObject.twoParamMethod( "firstParam", "secondParam" )
does not work. The error message in my language says something like "it is not possible to apply an index to a NULL-array".
Any hints? Thanks!