クラス名を検索する

読み込まれているアセンブリからクラス名を検索し、フルネームを取得するスクリプトを紹介します。

クラス名を検索するスクリプト

find-class.msh
param([String]$target)

if ($target -eq ""){return}
[AppDomain]::CurrentDomain.GetAssemblies() | foreach{$_.gettypes()} | `
where{$_.fullname -match $target} | write-host

利用方法

「DivideByZeroException」の検索
MSH C:\> find-class DivideByZeroException
System.DivideByZeroException
「DriveNotFoundException」の検索
MSH C:\> find-class DriveNotFoundException
System.IO.DriveNotFoundException
System.Management.Automation.DriveNotFoundException