Powershell IF: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Thomas (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „=Einfache IF Verzweigung= <pre> $x = 20 $y = 10 if ($x -gt $y) { '$x is greater than $y' } </pre> =IF mit ELSE= <pre> $x = 10 $y = 20 if ($x -gt $y) { '$x is g…“) |
Thomas (Diskussion | Beiträge) |
||
| (3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
=Einfache IF Verzweigung= | =Einfache IF Verzweigung= | ||
<pre> | <pre> | ||
| − | $x = | + | $x = $($args[0]) |
$y = 10 | $y = 10 | ||
if ($x -gt $y) | if ($x -gt $y) | ||
{ | { | ||
| − | + | "$x is greater than $y" | |
} | } | ||
</pre> | </pre> | ||
| + | |||
=IF mit ELSE= | =IF mit ELSE= | ||
<pre> | <pre> | ||
| − | $x = | + | $x = $($args[0]) |
$y = 20 | $y = 20 | ||
if ($x -gt $y) | if ($x -gt $y) | ||
{ | { | ||
| − | + | "$x is greater than $y" | |
} else { | } else { | ||
| − | + | "$x is less than $y" | |
| + | } | ||
| + | </pre> | ||
| + | =IF mit ELSE und ELSEIF= | ||
| + | <pre> | ||
| + | $x = $($args[0]) | ||
| + | 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" | ||
} | } | ||
</pre> | </pre> | ||
Aktuelle Version vom 8. November 2017, 20:06 Uhr
Einfache IF Verzweigung
$x = $($args[0])
$y = 10
if ($x -gt $y)
{
"$x is greater than $y"
}
IF mit ELSE
$x = $($args[0])
$y = 20
if ($x -gt $y)
{
"$x is greater than $y"
} else {
"$x is less than $y"
}
IF mit ELSE und ELSEIF
$x = $($args[0])
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"
}