0

I have a following batch(.bat file) command which is working great. However, i need to convert it into powershell command and need to run it through powershell. I have went through different ways that i have found online but none of them seems to work the way i want it to.

Batch command:

java -jar xyz.jar -url https://xyz.abc.com -user xyz123 -passwordHash abchgfqwfjhd1232bfyevt7676 -clientId GFGFhjxgsVGGF -clientSecret GFhjdhjdhdGGGbfsilwueibJGBjg -input C:\abc\Newfolder\xyz\  -v >> %logfile%

Till now i have just been able to run this basic powershell command. can someone please assist?

Powershell command:

Start-Process -FilePath https://xyz.abc.com
GiampaoloGabba
  • 1,428
  • 1
  • 15
  • 21
vishal
  • 5
  • 1
  • 1
    Use the command _nearly as is_ changing `java -jar …` to `java.exe -jar …` and `%logfile%` to `$logfile`. – JosefZ Jul 04 '19 at 15:56

1 Answers1

0

Maybe this helps:

 $logFile = "C:\temp\logFile.txt"
 Invoke-Expression "java -jar xyz.jar -url https://xyz.abc.com -user xyz123 -passwordHash abchgfqwfjhd1232bfyevt7676 -clientId GFGFhjxgsVGGF -clientSecret GFhjdhjdhdGGGbfsilwueibJGBjg -input C:\abc\Newfolder\xyz\  -v " | Out-File $logFile

Invoke-Expression docu, be aware that Invoke-Expression should only be used if the string you're invoking is under your control. Another alternative is the & (call-operator), check this stackoverflow answer, which explains the differences between them.

Hope that helps.

Moerwald
  • 10,448
  • 9
  • 43
  • 83