Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, April 15, 2013 6:42 PM
Hello - I have over a dozen+ powershell scripts on a server which I need to execute all of them simultaneously. How do I go about doing this? I also want to schedule this execution using task scheduler and then execute another dozen+ scripts upon the completion of the first batch.
Any help would be appreciated.
Thank you!
Rumi
All replies (12)
Monday, April 15, 2013 6:55 PM | 1 vote
Make one script that calls other 10 or w/e many scripts with invoke-command, have task scheduler execute program powershell.exe with arguments -NoLogo -NonInteractive -executionpolicy bypass -command "c:\PSScripts\scriptwithinvokecommands.ps1"
invoke-command -ComputerName $server { &'c:\psscripts\script1.ps1' }
9 more invokes for other scripts
Monday, April 15, 2013 7:43 PM
Thank you for the response. I'm new to PowerShell, can you please elaborate?
Rumi
Monday, April 15, 2013 10:31 PM | 1 vote
type get-help invoke-copmmand -detailed.
Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.
Wednesday, April 17, 2013 6:23 AM
Hi,
Any update about the issue?
Please also refer to the below link to save all those ps1 file into one:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b37070f0-5f87-414f-8bba-e3532e26a896
Hope this helps.
Regards,
Yan Li
If you have any feedback on our support, please click here
Cataleya Li
TechNet Community Support
Wednesday, April 17, 2013 3:03 PM
I am still new to powershell but my advice would be to turn the scripts into modules which is very easy to do. Then you can run these using powershell remoting or invoke-command and if you use the -inDisconnectedSession parameter it will not wait for the first one to complete before the next one starts.
Wednesday, April 17, 2013 6:09 PM
Hello - does this execute the scripts in parrallel?
Rumi
Wednesday, April 17, 2013 6:09 PM
these scripts need to run on a sharepoint server so they cannot be run remotely.
Thank you,
Rumi
Wednesday, April 17, 2013 9:12 PM
Have you tried powershell remoting before? It does depend how the scripts return results though? Are you outputting results to the pipeline?. Also yes the scripts will be run in parallell if you use -indisconnected session from what I understand.
Wednesday, April 24, 2013 5:27 AM
Hi,
Just checking in to see if the suggestions were helpful. Please let us know if you would like further assistance.
If you have any feedback on our support, please click here .
Cataleya Li
TechNet Community Support
Thursday, May 16, 2013 2:48 AM | 3 votes
Thank you all for your responses. Yes, they were somewhat helpful. However, what I ended up doing was scheduled the following bat file to run all my scripts. Please note that this will allow the first batch of scripts to run (1-4) simultaneously while there is a 5 second wait time in between. The 6th script will not start until the 5th script has completed.
start powershell.exe C:\scriptPath\script1.ps1
timeout 5
start powershell.exe C:\scriptPath\script2.ps1
timeout 5
start powershell.exe C:\scriptPath\script3.ps1
timeout 5
start powershell.exe C:\scriptPath\script4.ps1
timeout 5
powershell.exe C:\scriptPath\script5.ps1
REM ###############
start powershell.exe C:\scriptPath\script6.ps1
timeout 5
start powershell.exe C:\scriptPath\script7.ps1
timeout 5
start powershell.exe C:\scriptPath\script8.ps1
timeout 5
start powershell.exe C:\scriptPath\script9.ps1
timeout 5
Rumi
Monday, January 16, 2017 6:50 AM
Hi,
Can there be possibilty of creating 1 ps script which will execute in below manner. When i run the script it should give me options to select which powershell script to execute like..
if i press 1, it will execute a.ps1
if i press 2, it will execute b.ps1
if press 3, it will execute c.ps1
what should be the command for it.
Monday, January 16, 2017 7:25 AM
Hi,
Can there be possibilty of creating 1 ps script which will execute in below manner. When i run the script it should give me options to select which powershell script to execute like..
if i press 1, it will execute a.ps1
if i press 2, it will execute b.ps1
if press 3, it will execute c.ps1
what should be the command for it.
Please open a new question as your question has no relation to the current very old topic.
\(ツ)_/