Finding Methods with Specific Keywords

As such, .NET Framework is huge and full of stars, and it is not easy to discover interesting methods buried inside of it. You can use the next lines to find all methods with a given keyword:

$key = 'Kill'
[System.Diagnostics.Process].Assembly.GetExportedTypes() | Where-Object { $_.isPublic}
| Where-Object { $_.isClass } | Where-Object { @($_.GetMethods() | Where-Object {
$_.Name -like "*$key*" }).Count -gt 0 } | Select-Object -expandProperty FullName

Twitter This Tip! ReTweet this Tip!


Posted Oct 29 2010, 08:00 AM by ps1

Comments

Tobias wrote re: Finding Methods with Specific Keywords
on 10-29-2010 1:55 PM

The above tip will get you the type names hosting the methods. To actually get a list of method names with your keyword, try this:

[System.Diagnostics.Process].Assembly.GetExportedTypes() | Where-Object { $_.isPublic}| Where-Object { $_.isClass } | Foreach-Object { $_.GetMethods() |  Where-Object {  $_.Name -like "*$key*"} } | Select-Object DeclaringType, Name

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.