How can we help?

Using Auron SMS Component in PowerShell


The SMS Component is ready to be used in Powershell without any extra configuration steps.

The example script below sends an SMS messages from a GSM modem using the SMS Component API in PowerShell.

To run this script just copy and past it into notepad and save it as ‘sendfromgsm.ps1‘.

Open up a PowerShell prompt. Navigate to the directory where the script was saved. Run the script in PowerShell using the command: ‘.\sendfromgsm.ps1

$objGsm = new-object -comobject AxSms.Gsm
$objSmsMessage = new-object -comobject AxSms.Message

# Display SMS Component Version
write-host Auron SMS Component $objGsm.Version
write-host Build: $objGsm.Build `nModule: $objGsm.Module

# Open connection to the device
$objGsm.Open("COM1")
write-host Open, result: $objGsm.LastError `
  ($objGsm.GetErrorDescription($objGsm.LastError))
If ($objGsm.LastError -ne 0)
{ 
  $objGsm.Close()
  write-host Ready.
  exit
}

# Message: set all properties
$objSmsMessage.ToAddress       = "+3162312345678"
$objSmsMessage.Body            = "Just testing the Auron Software SMS Component"

# Send the Message
write-host Sending the Message...
$objGsm.SendSms($objSmsMessage)
write-host SendSms, result: $objGsm.LastError `
  ($objGsm.GetErrorDescription($objGsm.LastError))
write-host Message Reference (can be used with status reports): $objSmsMessage.Reference

$objGsm.Close()
write-host Ready.