Copying compiled C# code originally written in PowerShell. This topic contains 2 replies, has 3 voices, and was last updated by Richard Diphoorn 9 months, 2 weeks ago. Author Posts April 8, 2016 at 12:37 am #37401 Chris SalzgeberParticipant 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 #37408 Dave WyattModerator That's not quite how it works. Your PowerShell code gets compiled down to a .NET expression tree in the DLR (see https://msdn.microsoft.com/en-us/library/bb397951.aspx?f=255&MSPPError=-2147217396 ). It's not the same as translating PowerShell code into useful C# that you could copy. April 8, 2016 at 4:14 am #37409 Richard DiphoornParticipant 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 http://www.red-gate.com/products/dotnet-development/reflector/ Then use this function (yes, this code is from 2008 but still works): http://www.nivot.org/post/2008/10/30/ATrickToJumpDirectlyToACmdletsImplementationInReflector It's a bit tedious work, but I'm not aware of other methods to do it. 🙂 Author Posts You must be logged in to reply to this topic.