I'm trying to build a script that will provide me the listing of the method of a dll from a .net component.
Here's what I've done so far:
Param([String]$path)
if($path.StartsWith("["))
{
$asm = [Reflection.Assembly]::LoadWithPartialName($path)
$asm.GetTypes() | select Name, Namespace | sort Namespace | ft -groupby Namespace
}
else
{
$asm = [Reflection.Assembly]::LoadFile($path)
$asm.GetTypes() | select Name, Namespace | sort Namespace | ft -groupby Namespace
}
So basically the second part of the script (when providing the path of a dll) is working perfectly fine;
Running '.\GetDllMethods.ps1 -path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"' will provide me with all the members of the WinSCP dll.
What I want to achieve with the first part of the script is to get the same result by providing the name of the .net component using something like:
.\GetDllMethods.ps1 -path "[System.IO.StreamWriter]"
To get all the member of the StreamWriter component.
But I'm getting a null exception here.. Any hint ?
you can use the powershell cmdlet get-member
PS>[system.net.webclient]|get-member -MemberType method
TypeName : System.RuntimeType
Name MemberType Definition
---- ---------- ----------
AsType Method type AsType()
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
...
we can see there is a GetMethods method, so try :
[system.net.webclient].GetMethods()
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