Question:
i’m trying to run a script which will run another powershell script.
i need the first script to continue only after the other one is over.
something like:
start Copy.ps1
wait till Copy.ps1 is done
continue with the script
tried using the Invoke-Expression but it doesn’t have wait parameter.
Answer:
I think you easily can do it by calling the file like this:
1 2 3 4 5 6 7 8 9 10 11 |
<# here is some awesome code #> # Call P$ Script here & C:\Path\To\CopyScript.ps1 <# awesome code continues here #> |
it will call the whole script in Copy.ps1 and continues after copy.ps1 finished.
Other method is you set the whole script in copy.ps1 into a function.
in CopyScript.ps1:
1 2 3 4 5 6 |
function MyCopyFunction(){ # all code inside the Copy.ps1 is here } |
And in your new File:
1 2 3 4 5 6 |
# Call P$ Script here & C:\Path\To\CopyScript.ps1 # then call the function MyCopyFunction |
Greetz Eldo.Ob