Send message with powershell

Send message with powershell SearchSearch
Author Message
Kim Heikkinen
New member
Username: Zumi

Post Number: 4
Registered: 03-2019
Posted on Monday, February 17, 2020 - 02:58 pm:   

Hello!

I created a script that sends a reply message via Powershell.
For some reason it doesn't work. It seems that Invoke-WebRequest command + url brings the logon window only.

Has someone managed to get the sms sending working with Powershell?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 6095
Registered: 08-2008
Posted on Monday, February 17, 2020 - 05:50 pm:   

Hi,

Does the URL built in the script include &user=xxxxxx&password=yyyyyy parameters?

Can you share script details?

--
Des
NowSMS Support
Kim Heikkinen
New member
Username: Zumi

Post Number: 5
Registered: 03-2019
Posted on Friday, February 21, 2020 - 12:27 pm:   

Yes it includes it. Here is the command:


PS C:\Users\asd> Invoke-WebRequest -uri "http://localhost:8800/?PhoneNumber=123\&user=asd\&passw
ord=asd\&text=asd"


StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html>
<html lang="en">
<head>
<title>NowSMS Login</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="in...
RawContent : HTTP/1.1 200 OK
Connection: Keep-Alive
X-NowSMS-Login: true
Pragma: no-cache
Content-Length: 13098
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: text/html
Date: Fri, 21 Feb 2...
Forms : {loginForm}
Headers : {[Connection, Keep-Alive], [X-NowSMS-Login, true], [Pragma, no-cache], [Content-Length, 13098]...}
Images : {}
InputFields : {@{innerHTML=; innerText=; outerHTML=<input name="TOKEN" type="HIDDEN" value="6D3334C79AF">; outerT
ext=; tagName=INPUT; name=TOKEN; type=HIDDEN; value=6D3334C79AF}, @{innerHTML=; innerText=; outerHT
ML=<input name="USERNAME" style="width: 70%;" type="TEXT" autocapitalize="none">; outerText=; tagNa
me=INPUT; name=USERNAME; style=width: 70%;; type=TEXT; autocapitalize=none}, @{innerHTML=; innerTex
t=; outerHTML=<input name="PASSWORD" style="width: 70%;" type="PASSWORD" autocapitalize="none">; ou
terText=; tagName=INPUT; name=PASSWORD; style=width: 70%;; type=PASSWORD; autocapitalize=none}}
Links : {@{innerHTML=Show navigation; innerText=Show navigation; outerHTML=<a title="Show navigation" id="m
obilenav" href="#nav">Show navigation</a>; outerText=Show navigation; tagName=A; title=Show navigat
ion; id=mobilenav; href=#nav}, @{innerHTML=Hide navigation; innerText=Hide navigation; outerHTML=<a
title="Hide navigation" href="#">Hide navigation</a>; outerText=Hide navigation; tagName=A; title=
Hide navigation; href=#}, @{innerHTML=<span><div id="sendheader">Send Message</div></span>; innerTe
xt=
Send Message; outerHTML=<a aria-haspopup="true" onclick="return false;" href="#"><span><div id="sen
dheader">Send Message</div></span></a>; outerText=
Send Message; tagName=A; aria-haspopup=true; onclick=return false;; href=#}, @{innerHTML=Text; inne
rText=Text; outerHTML=<a onclick='return switchPage("/Send%20Text%20Message.htm");' href="/Send%20T
ext%20Message.htm">Text</a>; outerText=Text; tagName=A; onclick=return switchPage("/Send%20Text%20M
essage.htm");; href=/Send%20Text%20Message.htm}...}
ParsedHtml : System.__ComObject
RawContentLength : 13098



PS C:\Users\asd>
Kim Heikkinen
New member
Username: Zumi

Post Number: 6
Registered: 03-2019
Posted on Friday, February 21, 2020 - 12:30 pm:   

Damn I figured it out, it goes like this on Windows powershell:
Invoke-WebRequest -uri "http://localhost:8800/&PhoneNumber=123&user=asd&password=asd&text=asd"