2

I am trying to run a PowerShell command (DesktopAppConverter) and I'm getting an error saying it is finding an unknown positional parameter.

DesktopAppConverter -AppInstallPath 'C:\Program Files (x86)\Search Deflector' -Destination '.\AppxPackage\' -Installer '.\ClassicInstaller\SearchDeflector-Installer.exe' -InstallerArguments '/COMPONENTS="main"','/VERYSILENT','/DIR="C:\Program Files (x86)\Search Deflector"' -MakeAppx -PackageName '3945spikespaz.SearchDeflector' -Publisher 'CN=69331A0A-1F10-4A10-8A28-3627A09E25FD' -Version '0.0.3.0' -AppId 'SearchDeflector' -AppDisplayName 'Search Deflector' -AppDescription 'A small program that forwards searches from Cortana to your preferred browser and search engine.' -PackagePublisherDisplayName 'spikespaz' -PackageArch 'x86' -Sign -Verbose

I also tried replacing the single quotes with double quotes and escaping the quotes in the InstallerArguments array with backticks. No dice.

C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.1.4.0_x64__8wekyb3d8bbwe\DesktopAppConverter.ps1 : A positional parameter cannot be found that accepts
argument '/VERYSILENT'.
At line:1 char:1
+ &'C:\Program Files\WindowsApps\Microsoft.DesktopAppConverter_2.1.4.0_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [DesktopAppConverter.ps1], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,DesktopAppConverter.ps1

My guess is that it's splitting the parameters at the vert first space in the AppInstallPath string.

Jacob Birkett
  • 1,927
  • 3
  • 24
  • 49
  • I'm not too hopeful that it makes a difference, but given that `-InstallerArguments` is typed `[string]`, try passing the arguments as a _single string_: `'/COMPONENTS="main"' /VERYSILENT /DIR="C:\Program Files (x86)\Search Deflector"'`. Note that if `DesktopAppConverter.ps1` were an _advanced_ script (with `[CmdletBinding()]` and/or `[Parameter()]` attributes), it shouldn't accept passing an _array_ to a (scalar) `[string]` parameter - but if that were the case, you'd see a different error message (` Cannot convert value to type System.String.`) – mklement0 Oct 16 '18 at 02:14
  • @mklement0 Tried that as well. – Jacob Birkett Oct 16 '18 at 02:56
  • And you don't have any unexpected control chars. in your command line, or Unicode characters that look like their ASCII counterparts (e.g., a `,` which is full-width comma)? – mklement0 Oct 16 '18 at 03:08
  • How about this (no single quotes and doubling up double quotes): `"/COMPONENTS=""main""","/VERYSILENT","/DIR=""C:\Program Files (x86)\Search Deflector"""` ? – mjsqu Oct 16 '18 at 03:14
  • @mklement0 Nope. – Jacob Birkett Oct 16 '18 at 03:14
  • 1
    @mjsqu That did the trick! Add an answer so I can accept and vote. – Jacob Birkett Oct 16 '18 at 03:16
  • See my comment on msjqu's answer for why this _shouldn't_ make a difference - unless there is something unusual about your invocation not shown in the question. – mklement0 Oct 16 '18 at 03:30

0 Answers0