Unable to run *.exe from PowerShell

Welcome Forums General PowerShell Q&A Unable to run *.exe from PowerShell

This topic contains 1 reply, has 1 voice, and was last updated by

1 year, 9 months ago.

  • Author
  • #70792

    Points: 0
    Rank: Member

    I have a folder at C:\Folder that has files input.xml, output.xml and licensegenerator.xml. Licensegenerator.xml takes variables that we put into input.xml and creates a temporary license for one of our programs using the output.xml file. We typically do this via command line by navigating to the C:\Folder directory, then running the command:

    LicenseGenerator.exe "C:\Folder\input.xml" "C:\Folder\output.xml"

    I'm attempting to write a script to do the exact same thing in PowerShell, but I'm struggling... Here's what I have:

    $inputtest = "C:\Folder\Input.xml"
    $outputtest = "C:\Folder\Output.xml"
    $licensegen = "C:\Folder\LicenseGenerator.exe"
    invoke-command $licensegen "$inputtest" "$outputtest"

    When I run this, I get the error:

    Invoke-Command : A positional parameter cannot be found that accepts argument 'C:\Folder\Output.xml'.
    At line:5 char:1
    + invoke-command $licengegen "$inputtest" "$outputtest"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand

    I have also tried running with "Invoke-Expression" but get the exact same error (except it says "invoke-expression" at the beginning). Anybody have any idea what I'm doing wrong here?

  • #70796

    Points: 0
    Rank: Member

    Got it!

    & $licensegen "$inputtest" "$outputtest"

The topic ‘Unable to run *.exe from PowerShell’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort