Solved

Run / execute url from scheduled tasks using powershell

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

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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
Comment Utility
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
Comment Utility
This is the way to solve this in schedule tasks by using PowerShell.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now