Script to restart service

Cobra25
Cobra25 used Ask the Experts™
on
Hi Guys,

I need a script that will restart a specific service every 12 hours for server 2008 r2.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
sc stop "service"
sc start "service"

as a batch file and then put it in task scheduler to run?

ie: http://stackoverflow.com/questions/21240656/run-a-script-every-4-hours-with-task-scheduler
Will SzymkowskiSenior Solution Architect
Most Valuable Expert 2015
Top Expert 2015

Commented:
You can do this vary easily with powershell...
See the below example...

restart-service -Name BITS

Open in new window


Save the script as Restart.ps1

Launch a Powershell Script from Task Scheduler
http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

Will.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial