Thursday, July 14, 2011 5:11 AM
I have created a “launch.bat” file to open PS in my script directory and it works perfectly fine.
Start powershell -noexit -command cd D:\Scripts\Myscripts
I also have some .ps1 scripts in my script folder, and I run the below scripts at least five times a day on different machines, and follow the same sequence daily.
A) Browse to my script folder "D:\Scripts\Myscripts
B) run "..load ps1"
Is it possible to run the above scripts one after the other with one single “launch.bat “ file.
Thanks in advance
Thursday, July 14, 2011 6:33 AM
Just put all of them in another script file and lauch that script.
Friday, July 15, 2011 4:52 AM
I had tried that but it dint work, maybe i have not done it the correct way.
It would really help if you give me an example and maybe i will be able to create one by reffering the example.
Friday, July 15, 2011 9:29 AM
Create a file with a PS1 extransion and any name you like.
Put these lines in the file.
Set-Location D:\Scripts\Myscripts .\load ps1 .\format.ps1 .\install.ps1
.\<your new file name>/ps1
replace the <> and everything in the midde with the name of the new file.
Friday, July 15, 2011 3:25 PMModerator
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path . "$ScriptPath\load.ps1" . "$ScriptPath\format.ps1" . "$ScriptPath\install.ps1"
Put the above script in a file called D:\Scripts\MyScripts\Wrapper.ps1, then call this:
powershell.exe -command ". 'D:\Scripts\MyScripts\Wrapper.ps1'"
If this post was helpful, please click the little "Vote as Helpful" button :)
- Marked As Answer by Jonathan TylerModerator Saturday, July 16, 2011 1:20 PM
Friday, July 15, 2011 4:58 PM
Ok I clicked - now what?
Good example Trevor.
Thursday, July 21, 2011 6:02 AM
It worked, i added couple of more scripts and they all run in sequence with no issues.
Thanks for your help :)
I have One more question.
I have a new .ps1 script what has to be run with some additional parameter
I added this script and tried to run, how it fails with error “not recognized as the name of a cmdlet”
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path . "$ScriptPath\load.ps1" . "$ScriptPath\format.ps1" . "$ScriptPath\install.ps1" . "$ScriptPath\Primary-Connection.ps1 -Site MBX –Import"
If I run this manually it works
What do I need to do to run it when I call .\wrapper.ps1