PowerShell / Crescendo

a module for wrapping native applications in a PowerShell function and module
MIT License
399 stars 37 forks source link

Positional parameter cannot be found error for OriginalName with spaces when using -Verbose #131

Closed FH-Inway closed 2 years ago

FH-Inway commented 2 years ago

While doing the tutorial with azcmagent from the documentation, I ran into the issue that when one of the generated cmdlets was executed with the -Verbose switch, I got an error:

Write-Verbose: A positional parameter cannot be found that accepts argument 'Files\AzureConnectedMachineAgent\azcmagent.exe'.

This is because in the Crescendo configuration file, OriginalName is specified as OriginalName = "c:/program files/AzureConnectedMachineAgent/azcmagent.exe" Note the space between program and files.

The Export-CrescendoModule function (or more specifically the GetInvocationCommand method of the Command class) handles this by wrapping OriginalName in double quotes - except for this line:

https://github.com/PowerShell/Crescendo/blob/8a30182fed41c4374461f13c3acbe23baceee5f1/Microsoft.PowerShell.Crescendo/src/Microsoft.PowerShell.Crescendo.psm1#L467

FH-Inway commented 2 years ago

See pr #130 for a proposed change to add double quotes for this line, too.

theJasonHelmick commented 2 years ago

Thank you @FH-Inway for the pr -- pr accepted.