If you have an instance of your object (let's assume $o) you could call a
static method like this:
$o.GetType()::Test1(1234)
If you have a string for the method name you could build an expression and
use invoke-expression:
$methodName = "Test1"
$arg = 1234
$line = '$o.GetType()::' + $methodName + '($arg)'
invoke-expression $line
You can get the list of static methods using Get-Member:
$o | Get-Member -static
--
Nigel Sharples [MSFT]
Windows PowerShell Test
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"Doug" <Doug@discussions.microsoft.com> wrote in message
news:FE3C6232-FA59-4364-A0F7-7FDA9876F940@microsoft.com...
>I have a DLL with two methods one static and one not.
>
> public static int Test1(int p) { return 1; }
> public int Test2(int p) { return 2;}
>
> I use the [reflection.assembly] to load it no problem.
> In script I create an array of strings with the method names and do a
> New-Object on this class.
>
> I want to loop through the array and call the methods on the object with
> the
> same parameter.
>
> It does not work and I don't know how to call a static method without this
> syntax[Namespace.Class]::Method
>