0

I'm looking to get the java versions of all the Java on the machine.

 Get-ChildItem 'C:\Program Files*' -Include java.exe -Recurse | % { $_ -version } 

i'm able to get the results however am not able to run the commands to get the actual versions back.

C:\Program Files\Java\jre1.8.0_241\bin\java.exe -version
C:\Program Files\Vertiv\DSView 4\j2sdk\bin\java.exe -version
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe -version
C:\Program Files (x86)\Common Files\Oracle\Java\javapath_target_3553135156\java.exe -version

any other options appreciated.

mklement0
  • 382,024
  • 64
  • 607
  • 775
BostonMacOSX
  • 1,369
  • 2
  • 17
  • 38
  • 1
    In short: to invoke an executable whose name or path is stored in a variable or quoted string, you must use `&`, the [call (execute) operator](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Operators#call-operator-) – mklement0 Feb 24 '20 at 19:43
  • 1
    Therefore: `& $_ -version` – mklement0 Feb 24 '20 at 19:51

0 Answers0