Run powershell script (batch file) from another powershell script

11/01/2012 22:50

I found out, it dependes, if we are running powershell script from powershell ISE or powershell console.


When I need to call prepinac.ps1, or hop.bat from MasterScript.ps1..

for PS console use in MasterScript.ps1, (run as .\MasterScript.ps1 in console)

. .\prepinac.ps1

. .\hop.bat



for PS ISE - use in MasterScript.ps1  it's the same for running script F5, or to type it to PS command line.



if you use .\prepinac.ps1, error message is displayed. You have to change location to script directory.