Run an external Powershell script from the parent script

I have three scripts:
Parent.ps1
Child01.ps1, Child02.ps1

I would like to run the Parent.ps1 script and run either Child01.ps1 or Child02.ps1 from that script. The child script name will be fed in at the Parent.ps1 command line by the user.

This is what I have so far:

    # Call external Script to strip the Permissions.
    $CurrPath = (Get-Location).path
    $ScriptPath = "$CurrPath\Set-DomainGroupPermissions.ps1"
    $ArgumentList = @()
    $ArgumentList += $oHost.Name
    Start-Process -FilePath $ScriptPath -ArgumentList $ArgumentList

I’m not sure if this is working tho as there are no errors and no output from the child script. The child script looks like this:

param(
    [Parameter(Mandatory=$True)]
    $VMHost = ""
)
Write-Host "Working on host [$VMHost] permissions."
$esxcli = Get-EsxCli -VMHost $VMHost -V2
$ESXCLI_Args = $esxcli.system.permission.unset.CreateArgs()
$ESXCLI_Args.group = $true
$ESXCLI_Args.id = "MyDomain\ESX Admins"
$esxcli.system.permission.unset.invoke($ESXCLI_Args)

Write-Host "Finished working on host [$VMHost] permissions."

I’m thinking that the child script is running in another “space” where I cannot see the output.

Is there a way I can step-thru my parent script and when it calls the child script, step thru that as well?

Name Value


PSVersion 5.1.14393.7254
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.14393.7254
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

You can dot source your child script and call functions of the child script from inside your current process instead of starting a new process to run the script.

. "$PSScriptRoot\Set-DomainGroupPermissions.ps1"