/code-conversion

Code conversion command line tool for PowerShell and C#

Primary LanguageC#Apache License 2.0Apache-2.0

PowerShell to C# Code Conversion

Orginally a feature of PowerShell Pro Tools, this module provides the ability to convert between C# and PowerShell. No license required.

Installation

Install-Module CodeConversion

Usage

Convert from C# to PowerShell

Invoke-CodeConversion -CSharp 'class MyClass { 
    public object MyMethod()
    {
        return new Object();
    }
}'
<#
Outputs: 

function MyMethod
{
        return (New-Object -TypeName Object)
}

#>

Convert from PowerShell to C#

Invoke-CodeConversion -PowerShell 'Get-Process'
# Outputs: System.Diagnostics.Process.GetProcesses()