Could a windows scheduled task connect to a rest endpoint?

Starting with PowerShell 3.0 you can use the Invoke-RestMethod cmdlet.

Invoke-RestMethod -Uri "www.example.com/jobs/job1"

The advantage here is that it will deserialize it for you into an object if it's XML or JSON. For RSS or ATOM it will return the Item or Entry XML nodes. For text it will display the text.

You can read more here: https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/invoke-restmethod

Create the scheduled task with the details below:

Trigger: Daily, at your chosen time, repeat 12 hours for a duration of 1 day.

Actions:

Start a program: powershell

Arguments: -NoProfile -NonInteractive -File ".\YourScriptName.ps1"

Start in: C:\your_scripts

Given that you have created an object you can format this data any way you choose but that's beyond the scope of this question.


You can easily accomplish this with PowerShell and System.Net.WebClient.

Create a simple MyScriptName.ps1 file with the following contents:

$web = New-Object System.Net.WebClient
$str = $web.DownloadString("http://www.example.com/jobs/job1")
$str # not strictly necessary but if you run this in PowerShell you will get the response body of your endpoint

Then create a new scheduled task and add a new action to Start a program and use the following settings:

Program/script: powershell
Add arguments: .\MyScriptName.ps1
Start in: C:\The\Directory\You\Saved\Your\Script\In