Hello,
I am trying to get the script below to work in bulk, from a CSV file. The issue is that the variable for the Exchange mailbox alias $ExAlias is designed to grab just the first letter of the $FirstName variable and combine it with the entire $LastName variable. This works fine when I manually populate the $FirstName and $LastName variables, but I was wondering if I can use a CSV file that has FirstName and LastName as data, but still can use my trick of just grabbing the first initial of the FirstName and adding it to full LastName to construct the $ExAlsias variable. Below is how I do it without a CSV file.
$FirstName = ‘Some’
$LastName = ‘Newemployee’
$ExAlias = $FirstName.SubString(0,1)+$LastName
$ExtMail = ‘External.Mail@othercompany.com’
$username = ‘EMP7412’
$database = ‘EX-DB-05’
Enable-Mailbox -Identity $username -Alias $ExAlias -Database $database
New-MailContact -FirstName $FirstName -LastName $LastName -Name “${FirstName} ${LastName} CORP” -Alias “${FirstName}${LastName}CORP” -OrganizationalUnit “OU=Contacts,DC=mycompany,DC=com” -ExternalEmailAddress $ExtMail
Set-Mailbox $ExAlias -DeliverToMailboxAndForward $False -ForwardingAddress $ExtMail