PoshCode Archive  Artifact Content

Artifact 3bcb749d5233d79ae075e5572ded1e816cedab0b158c3a6a25f501543c66e6e9:

  • File werwerwer.ps1 — part of check-in [277b19502e] at 2018-06-10 14:16:28 on branch trunk — http://en.wikipedia.org/wiki/List_of_SMS_gateways (user: dvsbobloblaw size: 3390)

# encoding: ascii
# api: powershell
# title: werwerwer
# description: http://en.wikipedia.org/wiki/List_of_SMS_gateways
# version: 0.1
# type: script
# author: dvsbobloblaw
# license: CC0
# x-poshcode-id: 6471
# x-archived: 2016-08-13T22:13:07
# x-published: 2016-08-12T09:59:00
# You can send text messages with send-mailmessage. Really easy. I attempted to do something with it, not sure what though.
An attempt to send text messages to phones. 

Have you ever wrote a deamon script that notifies you when a server is down or something else. Wouldn't it be nice to get a TEXT (SMS) message.

Send-TextMessage -Port 587 -SmtpServer 'smtp.gmail.com' -UseSsl -Body 'Hello World' -From 'evilperson@gmail.com' -Subject '>=)' -Number '7238675309' -ServiceProvider Verizon -Credential (Get-Credential)

This will send a text message to 7238675309 from evilperson@gmail.com

This is pretty lame if you already know the person's text email address gateway thing.


    #Specifies the body (content) of the text message.

    #Specifies the address from which the message is sent.

    #Specifies the name of the SMTP server that sends the text message.

    #Specifies the subject of the text message. This parameter is required.

    #Specifies the phone number to which the text message is sent.

    #Specifies a user account that has permission to perform this action. The default is the current user.

    #Uses the Secure Sockets Layer (SSL) protocol to establish a connection to the remote computer to send mail. By default, SSL is not used.

    #Specifies an alternate port on the SMTP server.
    [ValidateRange(0, 2147483647)]

    #Carriers providing Short Message Service (SMS) transit via SMS gateways.

switch ($ServiceProvider) {
    'USCellular' {$Recipient="$Number@email.uscc.net"}
    'Verizon' {$Recipient="$Number@vtext.com"}
    'ATT' {$Recipient="$Number@vmobl.com"}
    'Sprint' {$Recipient="$Number@messaging.sprintpcs.com"}
    'Virgin' {$Recipient="$Number@vmobl.com"}
    'T-Mobile' {$Recipient="$Number@tmomail.net"}
    'Cricket' {$Recipient="$Number@sms.mycricket.com"}
    default {throw 'How did this happen?'}

$Information = @{Body=$Body;From=$From;SmtpServer=$SmtpServer;Subject=$Subject;To=$Recipient;Credential=$Credential;UseSsl=$UseSsl;Port=$Port}

    Send-MailMessage @Information
    throw "Awe, it didn't work."