Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Exit workflow when any error occurs.

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>