首页 > 学院 > 开发设计 > 正文

欢迎使用CSDN-markdown编辑器

2019-11-08 02:05:48
字体:
来源:转载
供稿:网友

Powershell条件操作符

比较运算符

-eq : 等于-ne : 不等于 -gt : 大于-ge : 大于等于-lt : 小于-le : 小于等于-contains : 包含-notcontains : 不包含PS C:Powershell> (3,4,5 ) -contains 2FalsePS C:Powershell> (3,4,5 ) -contains 5TruePS C:Powershell> (3,4,5 ) -notcontains 6TruePS C:Powershell> 2 -eq 10FalsePS C:Powershell> "A" -eq "a"TruePS C:Powershell> "A" -ieq "a"TruePS C:Powershell> "A" -ceq "a"FalsePS C:Powershell> 1gb -lt 1gb+1TruePS C:Powershell> 1gb -lt 1gb-1False

求反

-not : 求反运算符PS C:Powershell> $a= 2 -eq 3PS C:Powershell> $aFalsePS C:Powershell> -not $aTruePS C:Powershell> !($a)True

布尔运算

-and :和-or :或-xor :异或-not :逆PS C:Powershell> $true -and $trueTruePS C:Powershell> $true -and $falseFalsePS C:Powershell> $true -or $trueTruePS C:Powershell> $true -or $falseTruePS C:Powershell> $true -xor $falseTruePS C:Powershell> $true -xor $trueFalsePS C:Powershell> -not $trueFalse

比较数组和集合

PS C:Powershell> 1,2,3,4,3,2,1 -eq 333PS C:Powershell> 1,2,3,4,3,2,1 -ne 312421

验证一个数组是否存在特定元素

PS C:Powershell> $help=(man ls)PS C:Powershell> 1,9,4,5 -contains 9TruePS C:Powershell> 1,9,4,5 -contains 10FalsePS C:Powershell> 1,9,4,5 -notcontains 10True

转自:http://www.pstips.net/powershell-formulating-conditions.html


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表