Skip to content

Instantly share code, notes, and snippets.

@jmelosegui
Created July 3, 2017 19:21
Show Gist options
  • Save jmelosegui/47965cdf369fcefa8e812d7a74005c4b to your computer and use it in GitHub Desktop.
Save jmelosegui/47965cdf369fcefa8e812d7a74005c4b to your computer and use it in GitHub Desktop.
Reflect Powershell CmdLet using ICSharpCode ILSpy.

Reflect Powershell CmdLet using ICSharpCode ILSpy. Credit to Nivok Ink for his version using Redgate Reflector.

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