hello B
hello B

Reputation: 963

How to convert Powershell to C#

Is possible to convert PowerShell code .PS1 to C# code?

I'v been looking to it on google but I always find the contrary.

Reflector has the AddIn to convert DLL to PS Code, so I think it's possible..

Upvotes: 7

Views: 22978

Answers (2)

Mark Gibbons
Mark Gibbons

Reputation: 581

This open source tool can do it, but the output it generates currently is not great due to the fact that PowerShell is a fairly lax language and C# is quite strict. Powershell also has a lot of commandlet wrapper functions which makes it hard to even make a tool that can really automate this.

Upvotes: 1

Abdelali Laaraje
Abdelali Laaraje

Reputation: 377

You can try this Visual studio code extension : PowerShell Pro Tools for VS Code https://ironmansoftware.com/powershell-pro-tools-for-visual-studio-code/

enter image description here

Convert between C# and PowerShell code to easily take snippets of either language and convert it to the other. Quickly create P\Invoke functions in PowerShell from C# snippets found on sites like Pinvoke.net.

Upvotes: 3

Related Questions