반응형
- 조건문 비교 연산자
조건문 비교시 보통의 연산자인 =, <, > 기호 대신 약자를 사용한다.
- -eq : ==
- -ne : !=
- -lt : <
- -le : <=
- -gt : >
- -ge : >=
- IF문
$name = "Seoul"
if($name -eq "seoul"){
Write-Host "seoul == Seoul"
}
if($name -eq "Seoul"){
Write-Host "Seoul == Seoul"
}
- IF & ELSEIF
$name = "Seoul"
if($name -eq "Busan"){
Write-Host "Busan != Seoul"
}elseif($name -eq "Seoul"){
Write-Host "Seoul == Seoul"
}
- IF & ELSE
$name = "Seoul"
if($name -eq "Busan"){
Write-Host "Busan != Seoul"
}else{
Write-Host "Seoul == Seoul"
}
- 주의점
- elseif 사용시 else if로 쓰면 에러난다. (빈공간 없음)
- if, elseif, else 사용시 무조건 대가로 { } 가 있어야 한다.
반응형
'Windows 10 > PowerShell' 카테고리의 다른 글
PowerShell : Switch (0) | 2019.06.14 |
---|---|
PowerSehll : For, While, Break (0) | 2019.06.14 |
PowerShell : 주석 처리 (0) | 2019.06.14 |
PowerShell : 입력 & 출력 (0) | 2019.06.14 |
PowerShll : 관리자로 실행 (0) | 2019.06.14 |