본문 바로가기

Windows 10/PowerShell

PowerSehll : Try, Catch, Finally (예외 처리)

반응형

- Try, Catch, Finally

Try{
	에러나는이상한문자
}
Catch{
	Write-Host "이상한 문자가 있던데요?"
	Write-Host $_
}finally{
	Write-Host "에러와 상관없이 실행할꺼야!"
}
  • $_ : 에러 표출을 위해 사용

 

 

about_Try_Catch_Finally

About Try Catch Finally In this article --> SHORT DESCRIPTION Describes how to use the Try, Catch, and Finally blocks to handle terminating errors. LONG DESCRIPTION Use Try, Catch, and Finally blocks to respond to or handle terminating errors in scripts. T

docs.microsoft.com

 

반응형