Windows Powershell IF-ELSEIF-ELSE 语句
Where-Object 进行条件判断很方便,如果在判断后执行很多代码可以使用IF-ELSEIF-ELSE语句。语句模板:
代码如下:
If(条件满足){
如果条件满足就执行代码
}
Else
{
如果条件不满足
}条件判断必须放在圆括号中,执行的代码必须紧跟在后面的花括号中。
代码如下:
PS C:Powershell> $n=8
PS C:Powershell> if($n -gt 15) {"$n 大于 15 " }
PS C:Powershell> if($n -gt 5) {"$n 大于 5 " }
8 大于 5
PS C:Powershell> if($n -lt 0 ){"-1" } elseif($n -eq 0){"0"} else {"1"}
1 相关推荐
higheels 2020-08-03
ZoctopusD 2020-08-03
酷云的csdn 2020-08-03
higheels 2020-07-27
liushun 2020-06-28
zhendeshifeng 2020-06-22
Sabrina 2020-06-11
CARBON 2020-06-03
CARBON 2020-06-01
DBATips 2020-05-31
higheels 2020-05-29
applecarelte 2020-04-15
Yyqingmofeige 2020-03-28
yoshubom 2020-03-06
Yyqingmofeige 2020-03-02
SciRui 2020-02-26