Creation of Contacts, for Email to Text on Phone

At my healthcare organization a nursing leader needed to push alerts via email, to users Cell Phones. She had a list of phone numbers and names of the users (around 100). So when she sent me the list I asked if she could make another column with the providers next to them so I can automate it. Below is a script I created to create the Contacts. I also added comments on everything, to help a novice powershell user to better understand how everything works. Remember to Change the OU Location at the bottom of the script, Could probably make a new Parameter for that. Also, to run the command you would just copy and paste the function in Exchange Powershell then Run New-CellContact -FirstName John -LastName Doe -Provider Cricket -CellNumber 8774878777

Function New-CellContact
    Param (
        [parameter(Mandatory = $true)]
        #This means if you run New-CellContact, It will need this value to Continue
        [parameter(Mandatory = $true)]
        [parameter(Mandatory = $true)]
        [ValidateSet("ATT", "Sprint", "Cricket", "Tmobile", "Verizon", "StraightTalk", "MetroPCS")]
        #Validating Set means, when providing the cmdlet the data you will need to give it the one listed or it will fail
        [parameter(Mandatory = $true)]
        #Validating Pattern Uses RegEx This RegEx is saying there needs to be 10 Digits \d is Numbers anything more or less or with a letter will fail.
    #This switch is a faster IF statement Basically if $Provider = ATT then $CarrierEmail =
    Switch ($Provider)
        "ATT" { $CarrierEmail = "" }
        "Sprint" { $CarrierEmail = "" }
        "Cricket" { $CarrierEmail = "" }
        "Tmobile" { $CarrierEmail = "" }
        "Verizon" { $CarrierEmail = "" }
        "StraightTalk" { $CarrierEmail = "" }
        "MetroPCS" { $CarrierEmail = "" }
    #This builds out the Alias for the AD Object
    $Alias = 'Cell-Alerts-' + $FirstName + "-" + $LastName
    #This builds out the email address so
    $ForwardingEmail = $CellNumber + $CarrierEmail
    #Write-Host "Testing $Alias $ForwardingEmail" this is for testing
    #This is the command to actually build the object using the parameters given and throw it in the correct OU
    New-MailContact -Alias $Alias -DisplayName $Alias -Name $Alias -FirstName $FirstName -LastName $LastName -ExternalEmailAddress $ForwardingEmail -OrganizationalUnit ""

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s