Try catch exit works in function but not in workflow. How can I exit when any error occurs in a workflow?
workflow test
{
$servers = "c:\list.txt"
foreach -parallel ($server in get-content $servers)
{
try {Test-Connection -ComputerName $server -Count 1 -ErrorAction Stop -Quiet}#try
catch {write-warning "$server is not reachable from $env:COMPUTERNAME"
exit }#Catch
}#foreach
}
test
99upgrade