How do I run a *.exe file from PowerShell

Question:

I have a folder at C:\Folder that has files input.xml, output.xml and licensegenerator.exe. Licensegenerator.exe 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:

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

When I run this, I get the error:

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?

Answer:

You’re looking for the call operator (&):

Invoke-Command is essentially for running scriptblocks on other hosts and/or in other user contexts.

Source:

How do I run a *.exe file from PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply