Windows – How to schedule a task to call a URL

background-processscheduled-taskwindowswindows-server-2012-r2

I have an MVC app. I have a controller that when called runs a background process to query Active Directory and updates the database.

http://myapp/BackgroundTask/Run

I want to run this on a schedule (daily) without opening a browser. I see that there's a lot of third party solutions, is there something built in?

Best Answer

Use the Invoke-WebRequest cmdlet from Powershell.

In your task:

  • Action: Start a program
  • Program/script: powershell.exe
  • Arguments: -Command "Invoke-WebRequest http://myapp/BackgroundTask/Run"