Copying compiled C# code originally written in PowerShell.

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?

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.

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. :slight_smile: