0

Aim--
I need to call multiple webpages in a single powershell windows scheduler.

current implementation--

enter image description here

in 'Add arguments' section :

-ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadString(\"https://example1\")"

Output needed--
I have to call more than two webpages here. How can i do that?
Purpose is - I have multiple webpages to call and i don't want to create separate scheduler for every webpage.

lil-wolf
  • 372
  • 2
  • 15

2 Answers2

1
powershell -ExecutionPolicy unrestricted -Command "@('https://adventofcode.com/2020/day/1','https://adventofcode.com/2020/day/2') | ForEach-Object {(Invoke-WebRequest `$_).Content}"
  • Getting an error. Invoke-WebRequest : Invalid URI: The hostname could not be parsed. At line:1 char:99 + ... ode.com/2020/day/2') | ForEach-Object {(Invoke-WebRequest `$_).Conten ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], UriFormatException + FullyQualifiedErrorId : System.UriFormatException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand – lil-wolf Dec 28 '20 at 10:10
  • PS C:\Users\alHaos> $PSVersionTable Name Value ---- ----- PSVersion 5.1.19041.610 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.610 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 – Алексей Семенов Dec 28 '20 at 10:14
  • $PSVersionTable Name Value ---- ----- PSVersion 5.1.18362.1171 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.18362.1171 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 – lil-wolf Dec 28 '20 at 11:32
  • I checked. it is working with powershell. But it is not working with windows scheduler. I tired changing path to open powershell app in scheduler, still giving me error. Any idea for this one ? – lil-wolf Dec 31 '20 at 08:02
0

At the end, scripting worked! nothing else.
I was avoiding to make a script, just wanted to do it with scheduler only.

But anyways, here are the linkes which helped me-
How to setup a Powershell Script in Windows Task Scheduler with admin permissions?
https://www.windowscentral.com/how-create-and-run-your-first-powershell-script-file-windows-10

lil-wolf
  • 372
  • 2
  • 15