0
votes

I have a url that executes lots of javascript code. I want to open this from PowerShell to schedule.

But as it executes javascript code, PowerShell not opening this url properly.

What I tried?

Invoke-RestMethod -Uri "myurl"
Invoke-WebRequest -Uri "myurl"

both gives me error.

Invoke-RestMethod : My Apps
--> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());

gtag('config', 'UA-123456789-2');


    At line:1 char:1

+ Invoke-RestMethod -Uri "http://spos.rkapps.in/SendLCNotifyMails" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Note: Start-Process "myurl" runs as expected, as it opens a real browser but I want to schedule this when my server is on logoff mode so it does not runs.

How to open it?

1
Please show us the full error message (except the URI, if present)Mathias R. Jessen
@MathiasR.Jessen, question is updated with full error codeRamesh

1 Answers

0
votes

I think this could be easier done for you:

here is a script that just open a browser which goes to a website:

$browser = new-object -com “InternetExplorer.Application”
$browser.Navigate(“https://stackoverflow.com/”)
$browser.visible = $true