Files
Powershell-Training/1.Basic/12.Function_error.ps1

11 lines
285 B
PowerShell

function Test {
[CmdletBinding()] #turns into adv function
param(
[int32] $PingCount
)
Test-Connection google.com -Count $PingCount
Write-Error -Message "It' a trap" -ErrorAction Stop
}
try {Test -ErrorAction Stop} catch {Write-Output "Launch problem!" Write-Output $_}