Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Get Out of a Function

$
0
0

Hi,

I have a simple PowerShell script which contains just two functions, I would like to run through each of these functions, but in each one there is a condition where the function should terminate. so my script goes like this:

myfunc1
myfunc2
function myfunc1
{

If(some stuff)
{
things
}
ElseIf(some stuff)
{
things
}
Else
{
things
    terminate/exit this function now
}


if(some stuff)
{
things
terminate/exit this function now
}
else
{
things
}


}

function myfunc2
{

If(some stuff)
{
things
}
ElseIf(some stuff)
{
things
}
Else
{
things
    terminate/exit this function now
}


if(some stuff)
{
things
terminate/exit this function now
}
else
{
things
}

is this the correct way to call my functions consecutively, and how would i exit the first function so my script can continue with the second one?

thanks

Steve


Viewing all articles
Browse latest Browse all 2562

Trending Articles



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