Solved

Run / execute url from scheduled tasks using powershell

Posted on 2014-11-19
3
1,466 Views
Last Modified: 2014-11-25
Hi!

From scheduled tasks (Windows Server 2012) I need to call an url like "http://www.example.com/file.aspx" each night. The file ("file.aspx") does not return anything, it only contains code to send out remind emails and stuff like that.

As I understand I should use PowerShell, the only thing I don't understand is what arguments I should use if I only want to call / execute an url.

Is this the correct arguments for my needs:
powershell.exe -command "(new-object system.net.webclient).downloadstring('http://example.com/file.aspx')".

Or should I use "Invoke-WebRequest" like this:
PowerShell Invoke-WebRequest -Uri http://example.com/file.aspx -Method POST

Or should I use Invoke-RestMethod since I don't want to look at the HTTP response?

Or should I do something else?
0
Comment
Question by:webressurs
  • 2
3 Comments
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 40453525
Why use powershell? iexplorer.exe http:\\urlname.xxx\file.aspx is sufficient maybe an hour later another task  taskkill /im iexplore.exe  can be run.
0
 
LVL 1

Accepted Solution

by:
webressurs earned 0 total points
ID: 40456895
This was solved this way in Schedueld Tasks:

Program/script:
PowerShell.exe

Add arguments (optional):
Invoke-WebRequest -Uri http://www.example.com/file.aspx -Method GET
0
 
LVL 1

Author Closing Comment

by:webressurs
ID: 40464150
This is the way to solve this in schedule tasks by using PowerShell.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Set OWA language and time zone in Exchange for individuals, all users or per database.
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question