user3467917
user3467917

Reputation: 23

Powershell and calling function scope

It's possible to force Exit of a function Parent that call a Function Child, from function Child?
Example code:

function Parent
{
   Write-Host "I'm Calling Parent Function"
   Child
   Write-Host "Code...Code..."
}

function Child
{
   Write-Host "I'm Calling Child Function"
   # END function:Parent
   Write-Host "Parent Ended!"
}

PS> Parent
PS> I'm Calling Parent Function
I'm Calling Child Function
Parent Ended!

Any Idea?

Upvotes: 1

Views: 589

Answers (1)

CB.
CB.

Reputation: 60918

try this ( using break I think is the dos command or an internal powershell command because get-command break returns error)

function Child
{
   Write-Host "I'm Calling Child Function"
   break
   Write-Host "Parent Ended!"
}

Upvotes: 1

Related Questions