您现在的位置是:网站首页> 编程资料编程资料
Windows Powershell IF-ELSEIF-ELSE 语句_PowerShell_
2023-05-26
364人已围观
简介 Windows Powershell IF-ELSEIF-ELSE 语句_PowerShell_
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
您可能感兴趣的文章:
相关内容
- Windows Powershell Where-Object 条件过滤_PowerShell_
- Windows Powershell条件表达式之条件操作符_PowerShell_
- Windows Powershell创建对象_PowerShell_
- Powershell小技巧之去除多余的空格_PowerShell_
- Powershell小技巧之创建短网址_PowerShell_
- Powershell小技巧之查找脚本中的函数_PowerShell_
- Powershell小技巧之保存服务信息_PowerShell_
- Windows Powershell调用静态方法_PowerShell_
- Windows Powershell方法(对象能做什么)_PowerShell_
- Windows Powershell属性:描述对象是什么_PowerShell_
