1、if条件判断语句
引用内容
2、for循环语句
引用内容
3、while循环语句
引用内容
4、foreach循环语句
引用内容
参考资料
[1].Powershell IF-ELSE 条件:https://www.pstips.net/powershell-if-else-condition.html
[2].Powershell For 循环:https://www.pstips.net/powershell-for-loop.html
[3].Powershell Foreach 循环:https://www.pstips.net/powershell-foreach-loop.html
[4].从管道中删除对象:https://docs.microsoft.com/zh-cn/powershell/scripting/samples/removing-objects-from-the-pipeline--where-object-?view=powershell-7
复制内容到剪贴板
程序代码

if(1 -lt 2) { echo "true"} else {echo "false"}

true
2、for循环语句
复制内容到剪贴板
程序代码

for($i=1;$i -le 5;$i++){echo $i}

1
2
3
4
5
2
3
4
5
3、while循环语句
复制内容到剪贴板
程序代码

$i=1;for(;$i -le 5;){echo $i;$i++;}

1
2
3
4
5
2
3
4
5
4、foreach循环语句
复制内容到剪贴板
程序代码

foreach($item in 1..5){echo $item}

1
2
3
4
5
2
3
4
5
参考资料
[1].Powershell IF-ELSE 条件:https://www.pstips.net/powershell-if-else-condition.html
[2].Powershell For 循环:https://www.pstips.net/powershell-for-loop.html
[3].Powershell Foreach 循环:https://www.pstips.net/powershell-foreach-loop.html
[4].从管道中删除对象:https://docs.microsoft.com/zh-cn/powershell/scripting/samples/removing-objects-from-the-pipeline--where-object-?view=powershell-7