0

Is it possible to find the files related to specific commands or config files? For example I want to know the full detail of what happens when I type a command such 'add-appxPackage'? I know what is required for it, but I want to know the coding behind it

  • "find the files related to specific commands or config files", I'm not sure what you're looking for here. Can you explain or give an example? What kind of "files" are you expecting to find? "I want to know the coding behind it" What do you mean by this? You want to see the source code for the commandlet itself? Is this the info you're looking for? – Ƭᴇcʜιᴇ007 Jan 5 '16 at 22:04
  • How does it execute there must b some dll or something with the instructions, of everything that happens behind the screen? – Dev_anon101 Jan 5 '16 at 22:05
  • Chances are that PowerShell functions are using DLL functions exported by standard Windows libraries. – Michael Jan 5 '16 at 22:06
  • Unfortunately, Windows is not Open Source. Decompilers, even for .NET, are also useless for anything but basic code. – Daniel B Jan 5 '16 at 22:17
4

For compiled Cmdlets, you can get the path to the .dll with:

(Get-Command Get-ChildItem).DLL

(Replace Get-ChildItem with the cmdlet you are interested in)

Once you know the path to the .dll, you can open it with a .NET disassembler like dotPeek:

& dotPeek64.exe (Get-Command Get-ChildItem).DLL

Source of above answer (StackOverflow)

Example:

Running (get-command add-appxPackage).dll on my system returns:

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Windows.Appx.PackageManager.Commands\v4.0_6.3.0.0__31bf3856ad364e35\Microsoft.Windows.Appx.PackageManager.Commands.dll

For more info check out this entire StackOverflow Q&A:

Can we see the source code for PowerShell cmdlets?

  • As an alternative, you could probably watch a PowerShell script using an API watcher, such as "API Monitor" by rohitab (I have never actually used it, so I make no statement of its effectiveness or safety). – Michael Jan 5 '16 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.