?
Solved

Run / execute url from scheduled tasks using powershell

Posted on 2014-11-19
3
Medium Priority
?
1,916 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

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

Bringing Advanced Authentication to the SMB Market

WatchGuard announces the acquisition of advanced authentication provider, Datablink, with one mission – to bring secure authentication to SMB, mid-market, and distributed enterprises with a cloud-based solution, ideal for resale via their established channel & MSSP community.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.
Suggested Courses

762 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