You can use SendKeys to send a F5 key to the process like this, let's say it's the content of main.ps1
:
Add-Type -AssemblyName System.Windows.Forms
Start-Process powershell_ISE "$PSScriptRoot\test.ps1"
# Wait a bit
Start-Sleep -Seconds 2
# Press F5
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
Then it opens the test.ps1
file which I assume is located beside the current script.
Note: Do not test this solution in ISE, because once the main script is running, it cannot run test.ps1
. So, to test, in a shell command line, run the main script like this:
powershell.exe c:\myfiles\main.ps1