Send SMS via modem and Powershell

$comport = "COM10"
$msg = get-date
$ext = "+45"
$number = $ext + "12345678"


$serialPort= new-Object System.IO.Ports.SerialPort $comport,9600,None,8,one
$serialPort.open()
$serialPort.Write("E1")
$serialPort.Write("AT+CMGF=1`r`n") ; $serialPort.Readline()
$serialPort.Write("AT+CMGS=`"$number""`r`n"); $serialPort.Readline()
$serialPort.Write("$msg`r`n") ; $serialPort.Readline()
$serialPort.Write($([char] 26))
$serialPort.Readline()
$serialPort.Readline()
$serialPort.Readline()
$serialPort.Readline()
$serialPort.Readline()
$serialPort.Readline()
$serialPort.Close()

Leave a Reply

Your email address will not be published. Required fields are marked *