Author Posts

April 8, 2016 at 12:37 am

My understanding of PowerShell is that since 3.0, advanced functions written in PowerShell are ultimately compiled and executed in C#. Is there a means by which I can inspect or copy the compiled C# equivalent of code I've authored in PowerShell?

April 8, 2016 at 4:12 am

That's not quite how it works. Your PowerShell code gets compiled down to a .NET expression tree in the DLR (see ). It's not the same as translating PowerShell code into useful C# that you could copy.

April 8, 2016 at 4:14 am

I'm not a developer, say don't take anything granted I will say to you.

But you need a .NET reflector tool for this. Something like

Then use this function (yes, this code is from 2008 but still works):

It's a bit tedious work, but I'm not aware of other methods to do it. 🙂