Reflect Powershell CmdLet using ICSharpCode ILSpy. Credit to Nivok Ink for his version using Redgate Reflector.
Created
July 3, 2017 19:21
-
-
Save jmelosegui/47965cdf369fcefa8e812d7a74005c4b to your computer and use it in GitHub Desktop.
Reflect Powershell CmdLet using ICSharpCode ILSpy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Spy-Cmdlet { | |
param( | |
[Management.Automation.CommandInfo]$command | |
) | |
if ($input) { | |
trap { $_; break } | |
$command = $input | select -first 1 | |
} | |
# resolve to command if this is an alias | |
while ($command.CommandType -eq "Alias") { | |
$command = Get-Command ($command.definition) | |
} | |
$name = $command.ImplementingType | |
$dll = $command.DLL | |
Write-Host $name | |
$inspector = "C:\dev\utils\ILSpy\ILSpy.exe" | |
& $inspector $dll /navigateTo:T:$name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment