Requires PowerShell Pro Tools​
Converts PowerShell script to C# code.
ConvertTo-CSharp -PowerShellScriptFile <FileInfo>
ConvertTo-CSharp -PowerShellScriptPath <String>
ConvertTo-CSharp -PowerShellScript <String>
ConvertTo-CSharp -ScriptBlock <ScriptBlock>
Converts PowerShell script to C# code. You can specify a path, PowerShell script text or a PowerShell script block.
PS C:\> ConvertTo-CSharp -PowerShellScriptPath .\*.ps1
Converts all PS1 files in the current directory to C# code. Returns an array of the contents of the files.
PS C:\> ConvertTo-CSharp -PowerShellScript "Get-Process"
Converts the specified PowerShell script to C# code.
PS C:\> ConvertTo-CSharp -ScriptBlock { Get-Process }
Converts the specified PowerShell ScriptBlock to C# code.
PS C:\> Get-ChildItem .\*.ps1 | ConvertTo-CSharp
Converts the piped PS1 files to C#
A FileInfo for a PS1 or PSM1
Type: FileInfoParameter Sets: PathByPipelineAliases:​Required: TruePosition: NamedDefault value: NoneAccept pipeline input: True (ByValue)Accept wildcard characters: False
The contents of a PowerShell script
Type: StringParameter Sets: TextAliases:​Required: TruePosition: NamedDefault value: NoneAccept pipeline input: True (ByValue)Accept wildcard characters: False
The path to a PS1 or PSM1 file.
Type: StringParameter Sets: PathAliases:​Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: True
A PowerShell ScriptBlock
Type: ScriptBlockParameter Sets: ScriptBlockAliases:​Required: TruePosition: NamedDefault value: NoneAccept pipeline input: True (ByValue)Accept wildcard characters: False
System.Management.Automation.ScriptBlock