Powershell for循環語句示例
阿新 • • 發佈:2018-01-12
item 關註 ado 獲取 it資訊 shell http ima 資訊 示例一
for ($counter = 1;$counter -le 10;$counter ++)
{
"loop number $counter"
}
<#
loop number 1
loop number 2
loop number 3
loop number 4
loop number 5
loop number 6
loop number 7
loop number 8
loop number 9
loop number 10
#>
示例二
for ($i = 1; $i -lt 99; $i++) { for ($counter = 0;$counter -lt 5;$counter++) { if($counter -eq 2) { continue } Write-Host "processing item $i,$counter" } }
結果
processing item 94,0 processing item 94,1 processing item 94,3 processing item 94,4 processing item 95,0 processing item 95,1 processing item 95,3 processing item 95,4 processing item 96,0 processing item 96,1 processing item 96,3 processing item 96,4 processing item 97,0 processing item 97,1 processing item 97,3 processing item 97,4 processing item 98,0 processing item 98,1 processing item 98,3
請關註下方公眾號,以便獲取更多IT資訊:
Powershell for循環語句示例