In one of my powershell scripts - before starting a Java program - I am echoing the version of the java being used. The PS code looks quite harmless like so:
...
Write-Output "Java version:"
Write-Output "-------------"
java -version
...
The above snippet works perfectly, when I execute in a normal powershell window or as part of the startup script. The output is as expected:
Java version:
-------------
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
But when I execute the exactly same inside the PowerShell ISE (which I normally like to use as it is often quite helpful and convenient when developing and debugging scripts) I get:
Java version:
-------------
java : java version "1.8.0_202"
At D:\Projects\gwtp-demo\mms-specifics\etc\powershell\define_gwtp-demo_profile.ps1:50 char:1
+ java -version
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (java version "1.8.0_202":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
What's wrong here? Why do I get this additional PS gibberish here? It seems as if PS (or the ISE?) is trying to somehow interpret that output (which is of course NOT what I want or expect. How would I have to call this "correctly" (in PS terms) to avoid such additional output?