[PowerShell]循环遍历foreach

1. 循环遍历 foreach

$a='a','b','c'
foreach ($i in $a)
{
    echo $i
}

a
b
c

2. 循环遍历 foreach-object

$a | ForEach-Object{
    echo $_
}

a
b
c

3. for循环

for ($counter = 1;$counter -le 10;$counter ++)
{$counter}

END

posted @ 2021-08-13 14:04  LeoShi2020  阅读(982)  评论(0编辑  收藏  举报