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 [String]$FirstName, [parameter(Mandatory = $true)] [String]$LastName, [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 [String]$Provider, [parameter(Mandatory = $true)] [ValidatePattern("\d{10}")] #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. [String]$CellNumber ) #This switch is a faster IF statement Basically if $Provider = ATT then $CarrierEmail = @mms.att.net Switch ($Provider) { "ATT" { $CarrierEmail = "@mms.att.net" } "Sprint" { $CarrierEmail = "@messaging.sprintpcs.com" } "Cricket" { $CarrierEmail = "@mms.mycricket.com" } "Tmobile" { $CarrierEmail = "@tmomail.net" } "Verizon" { $CarrierEmail = "@vtext.com" } "StraightTalk" { $CarrierEmail = "@vtext.com" } "MetroPCS" { $CarrierEmail = "@mymetropcs.com" } } #This builds out the Alias for the AD Object $Alias = 'Cell-Alerts-' + $FirstName + "-" + $LastName #This builds out the email address so 7708278377@vtext.com $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 "Contoso.int/Contacts" }