################################################################################# ## Import data from the CSV file and store it in variable "$data" ## ################################################################################# $data = import-csv $args[0] ################################################################################# ##Cycle through each row from the CSV and feed the column values into variables## ##We also encrypt the password, as the "New-Mailbox" command does not accept ## ##plain text value for the "-Password" option ## ################################################################################# foreach ($i in $data) { $name = $i.Name $first = $i.First $last = $i.Last $alias = $i.First[0] + $i.Last $upn = $alias + "@" + $i.FQDN $ou = $i.ou $encryptedpass = ConvertTo-SecureString -AsPlainText $i.Password -Force new-mailbox -Name $name -Password $encryptedpass -UserPrincipalName $upn -OrganizationalUnit $ou -ResetPasswordOnNextLogon $false -Firstname $first -LastName $last }