Do you worry about the safety of your friends, family, and coworkers? It seems like every day there is a report of an active shooter or a natural disaster that is affecting people, businesses, and entire communities. In the interest of emergency preparedness at work, here is a way to communicate quickly to your co-workers should such an event take place.
Text messaging is a more effective means of communication than email in an emergency. Powershell is a valuable task automation tool put to good use to create a script that sends a text message to the group of your choosing. If you’d prefer a paid service, then AtHoc or RapidReach may be the solution for you. For those more frugal, and who also have an Exchange server, you can configure this without any additional costs or changes to your infrastructure.
Here are the steps:
##########################################################These variables define authentication to the email server. The red text needs to be #updated to reflect your environment. Don't declare a ‘to’ field, as it's used at the #end. Modify the from,body,sub,creduser,credpass,smtpserver,and port fields.
$From = "emergencytest@yourdomain.com"
$Body = "This is a test of the WatchPoint emergency broadcast system. This is only a test."
$Sub = "Test of the WatchPoint emergency broadcast system"
$CredUser = "myuser@mydomain.com"
$CredPass = "password" | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.Pscredential -Argumentlist $CredUser,$CredPass
$SmtpServer = "mail.mydomain.com"
$Port = "587"
#Declare the csv paths. The text in red will need to be updated to reflect your #environment.
$exportmembers = "C:\test\watchpointdata.csv"
$exportresults = "C:\test\results.csv"
#Replace “WatchPointData” with your groups actual name. Keep the “”. This #section collects all of the members that belong to our hidden distribution group #and exports to a csv.
$members = get-adgroupmember "WatchPointData" | select-object -property "SamAccountName" | export-csv $exportmembers
#Nothing needs changed here. This section collects the name, login, and mobile #phone number for each member of the group and is used in the next section.
Import-CSV -Path $exportmembers | ForEach-Object {
Get-ADUser -Filter "SamAccountName -like '*$($_.SamAccountName)*'" -Properties MobilePhone,UserPrincipalName,Name | select Name,UserPrincipalName,MobilePhone
} | Export-CSV $exportresults -NoTypeInformation
#Nothing needs changed here. This section gathers just the "MobilePhone" number #that we exported from the above section.
$textnumbers = import-csv $exportresults | % {$_.MobilePhone}
#Nothing needs to be changed here. This section sends an email as text to each #user.
ForEach($cellnumber in $textnumbers)
{
Send-MailMessage -To $cellnumber -From $From -Body $Body -Subject $Sub -Credential $Credentials -SmtpServer $SmtpServer -Port $Port
}
#End of Script
#########################################################
To send a real emergency message:
Hopefully you never have to use the script, but if you do, you now have an easy way to notify all of your employees about an emergency situation and get the message out to them quickly.