title: Powershell: list members of a .net component
body: <p>I'm trying to build a script that will provide me the listing of the method of a dll from a .net component.</p>
  
  <p>Here's what I've done so far:</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p>So basically the second part of the script (when providing the path of a dll) is working perfectly fine;</p>
  
  <p>Running '.\GetDllMethods.ps1 -path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"' will provide me with all the members of the WinSCP dll.</p>
  
  <p>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: </p>
  
  <p>.\GetDllMethods.ps1 -path "[System.IO.StreamWriter]"</p>
  
  <p>To get all the member of the StreamWriter component.</p>
  
  <p>But I'm getting a null exception here.. Any hint ?</p>