본문 바로가기

Windows 10/PowerShell

PowerSehll : For, While, Break

반응형

- For

For($i=0; $i -lt 10; $i++){
    Write-Host $i
}
 

about_For

About For In this article --> Short description Describes a language command you can use to run statements based on a conditional test. Long description The For statement (also known as a For loop) is a language construct you can use to create a loop that

docs.microsoft.com

 

 

- While

$i=0

While($i -lt 6){
    Write-Host $i
    $i++
}
 

about_While

About While In this article --> SHORT DESCRIPTION Describes a language statement that you can use to run a command block based on the results of a conditional test. LONG DESCRIPTION The While statement (also known as a While loop) is a language construct f

docs.microsoft.com

 

 

Break

for($i=0; $i -lt 100; $i++)
{
    Write-Host $i
    if($i -eq 5)
    {
        break
    }
}
 

about_Break

About Break In this article --> SHORT DESCRIPTION Describes a statement you can use to immediately exit Foreach, For, While, Do, or Switch statements. LONG DESCRIPTION When a Break statement appears in a loop, such as a Foreach, For, or While loop, the Bre

docs.microsoft.com

 

반응형

'Windows 10 > PowerShell' 카테고리의 다른 글

PowerShell : Array, 동적 배열  (0) 2019.06.14
PowerShell : Switch  (0) 2019.06.14
PowerShell : If, ElseIf, Else  (0) 2019.06.14
PowerShell : 주석 처리  (0) 2019.06.14
PowerShell : 입력 & 출력  (0) 2019.06.14