Powershell IF: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 20: Zeile 20:
 
</pre>
 
</pre>
 
=IF mit ELSE und ELSEIF=
 
=IF mit ELSE und ELSEIF=
</pre>
+
<pre>
 
$x = 10
 
$x = 10
 
if ($x -eq 20)
 
if ($x -eq 20)

Version vom 8. November 2017, 19:59 Uhr

Einfache IF Verzweigung

$x = 20
$y = 10
if ($x -gt $y)
{
'$x is greater than $y'
}

IF mit ELSE

$x = 10
$y = 20
if ($x -gt $y)
{
'$x is greater than $y'
} else {
'$x is less than $y'
}

IF mit ELSE und ELSEIF

$x = 10
if ($x -eq 20)
{
   '$x is 20'
} elseif ($x -eq 15) 
{
   '$x is 15'
} elseif ($x -eq 10) 
{
   '$x is 10'
} else 
{
   'Value of $x not known'
}