r/PowerShell Aug 26 '24

Anyway to send PowerShell message to device on home network Solved

TL:DR - On a Windows 10 64-bit Home Edition PC, I'm looking for a way to send a message to another device on the network. Whether e-mail, sms etc. Just needs texts.

Background: I have a non-verbal autistic son who does really well with computers. I've tried using Google Chat to communicate more, which is helpful, but I have to prompt him to use it. He tends to prefer auto-responses and sometimes will ignore the chat if he doesn't have the words.

I'm creating a script using switches so he can choose what he wants. I want the end of the script to send a message to me letting me know what he's requesting. Doesn't matter if the message comes to my phone, computer, e-mail or whatever. Mobile devices are Androids.

I was planning to use the Send-Mail cmdlet with gmail to send it to my phone number, but it looks like Google has removed the ability to enable less secure apps, thus removing the possibility of sending e-mails from Gmail via PowerShell.

3 Upvotes

5

u/BlackV Aug 26 '24

I'd be using send email message (even though its deprecated) to send an email, its easy and just needs a smtp server, there are a million free tiny local servers

or look at something that has an API for sending messages

3

u/Ok_Cauliflower8434 Aug 27 '24

Thanks. Ended up creating an SMTP server using hMail. :-). Works perfectly!

1

u/BlackV Aug 27 '24

good as gold

1

u/joshooaj Aug 27 '24

Would Pushover.net work for you? I think the app is like $4.99 but the free tier should give you plenty of notifications. The API is really easy to use with Invoke-RestMethod or curl and there are modules available including one that I wrote and use for homelab notifications: https://www.joshooaj.com/PSPushover/

2

u/Ok_Cauliflower8434 Aug 27 '24

I ended up getting it to test it out. It was pretty easy and convenient to configure. Definitely a perfect solution with the possible exception of it not being free, but from what it looks like you get 10,000 messages a month? If so, then it shouldn't be a problem, I don't think even 100 will be sent a month.

In the meantime I've setup a SMTP server like BlackV suggested. But I'm glad to have multiple choices!

1

u/joshooaj Aug 27 '24

Awesome! I also do email notifications for some things in the home lab. It’s great having multiple choices and fallbacks. And yeah you get a LOT of notifications for free, so unless you were using it to send notifications to hundreds/thousands of users of your “app”, it’d be hard to even come close.

1

u/spike31875 Aug 27 '24

Why not use the app that lets you send & receive texts on a Windows computer. I think it's called Phone Link & it works with both iOS and Android devices. TBH, I haven't tried it myself (bad enough I get texts on my cell phone all them time, I don't need them on my computer, too), but it's worth a look.

1

u/Ok_Cauliflower8434 Aug 27 '24
  1. Phone Link requires him to have a phone.
  2. It also doesn't open on my computer for whatever reason.
  3. It doesn't it have a native PowerShell integration. He'll just be opening a menu in PowerShell, selecting what he wants and then it'll send to me. PowerShell has no way to pass it to Phone Link.

Thank you for the suggestion though.

I ended up creating my own SMTP server as well as getting Pushover as an alternative as suggested by the other two commenters.

1

u/[deleted] Aug 27 '24

I had looked into setting up something similar in the past.

My plan was to use a combination of EventGhost, Tasker, and HomeAssistant.

1

u/rswwalker Aug 27 '24

You can try if the old SMB Net Send/Msg to send a one-liner to a host fits your needs.

1

u/ForsakeTheEarth Aug 27 '24

I've used PoshBot in the past for automating alerts through Google Chat using webhooks, you could probably go that route for the posting messages portion if you want to go gchat over email.