code-conversion
code-conversion copied to clipboard
CodeConversion does not work at all (in a Sandbox)
I started a fresh Sandbox and followed your instructions:
PS C:\Users\WDAGUtilityAccount> Install-Module CodeConversion
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\WDAGUtilityAccount\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Users\WDAGUtilityAccount> ConvertTo-PowerShell -Code 'System.Diagnostics.Process.GetProcesses()'
ConvertTo-PowerShell : A parameter cannot be found that matches parameter name 'Code'.
At line:1 char:22
+ ConvertTo-PowerShell -Code 'System.Diagnostics.Process.GetProcesses() ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-PowerShell], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,PowerShellToolsPro.Cmdlets.ConvertToPowerShellCommand
PS C:\Users\WDAGUtilityAccount> ConvertTo-CSharp -Code 'Get-Process'
ConvertTo-CSharp : A parameter cannot be found that matches parameter name 'Code'.
At line:1 char:18
+ ConvertTo-CSharp -Code 'Get-Process'
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-CSharp], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,PowerShellToolsPro.Cmdlets.ConvertToCSharpCommand
PS C:\Users\WDAGUtilityAccount>
Unfortunately it didn't work at all. Am I doing something wrong or is this a bug?
The parameter "code" that is provided in the example isn't existing anymore you should use one of these parameters:
[Parameter(Mandatory = true, ParameterSetName = "PathByPipeline", ValueFromPipeline = true)]
public FileInfo CSharpFile { get; set; }
[Parameter(Mandatory = true, ParameterSetName = "Path")]
public string CSharpFilePath { get; set; }
[Parameter(Mandatory = true, ParameterSetName = "Text", ValueFromPipeline = true)]
public string CSharpCode { get; set; }
Can you please try version 2.0?