Solved

Run / execute url from scheduled tasks using powershell

Posted on 2014-11-19
3
1,680 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 81

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

732 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