9

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?

19

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"
  • 1
    How to use Integrated Authentication? – Jack Jan 31 '17 at 17:15
  • Note: this only works in PowerShell 3 and up (to check your version, type get-host in powershell). In lower versions you'll need to call a separate powershell script, like in stackoverflow.com/questions/17486205/… – DdW Sep 27 '17 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.