Solved

Run / execute url from scheduled tasks using powershell

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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 transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

717 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