I'd basically like to use reflection in Powershell, and after dynamically finding the methods I'd like to invoke using standard powershell commands, I ended up with a MemberDefinition object and not much clue as to how to invoke it. I'm not positive I can, so if you have experience you can just say not to do it this way. I know I can drop into the Assembly namespace, but didn't know if I could do something like this:
$method = $ie | get-member -type method | ? { $_.name -eq 'span' }
invoke-member $ie $method
The $method
variable is of type Microsoft.PowerShell.Commands.MemberDefinition, is this even possible?
Thanks, Matthew
Sounds like you're pretty familiar with .NET, why not just drop down and use reflection directly?
PS> $d = Get-Date
PS> $t = $d.GetType()
PS> $t.InvokeMember("ToUniversalTime", "Public,InvokeMethod,Instance", $null, $d, $null)
Saturday, March 31, 2012 3:10:51 AM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With