Good afternoon everyone :) I know practically nothing about powershell I'm testing the following code (It's a test)
$java = Test-Path -Path "C:\Program Files (x86)\Java\jre1.8.0_321/README.txt" -PathType Leaf
if ($java -eq False)
{
Write-Output "No Instalanda"
}
elseif ($java -eq True)
{
Write-Output "Instalada"
}
pause
I create a variable with a command and with if and elseif I check if it is equal to True or False and according to the output I show a message. There is no way to make it work. If I put True or False in quotes, it always gives me an error.
What's wrong with the example I gave? Thank you all
Ok, I've seen how...
An example can illustrate the difference between if and elseif.
if is a new test, independent of the result of the previous test. elseif has no effect if the previous test succeeded.
In the example, assuming java is not installed, the first two trials only result in one line of output, while the last trial results in two lines.