Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I tried things out and not with much success. I don't want to know the whole solution for this problem, but where should I start (or maybe there already exist a solution)? Should I better convert the excel file to CSV or XML? Or maybe should I put some C# in it ?

Here are some more details:

  1. Attributes that should be readed and then filled in the mailbox: Name, Lastname, Display Name, Alias, e-mail(genrated from name and lastname).
  2. Checkbox must be unchecked: "Automatically update e-mail adresses based on e-mail adressess policy"
  3. Generate e-mails from the names with addtional domain (example: Name: Dennis, Lastname: Ritchie, e-mail:[email protected]).
share|improve this question
Welcome to Stack Overflow! You don't need to add a signature to your posts - your user card is automatically displayed below them. – Artemix Jul 9 at 10:48

2 Answers

CSV is certainly the easiest. You can then use

Import-CSV foo.csv

to read the file. Provided you used the appropriate column header names in the first row you can use them directly:

Import-CSV foo.csv | ForEach-Object { $_.Lastname; $_.'Display Name', <# etc. #> }

Enable-Mailbox seems to be the command to create Exchange mailboxes.

share|improve this answer
Thank you Joey ! – Albert1n0 Jul 11 at 7:21
up vote 0 down vote accepted
$path = "C:\Scripts\05-Script\Contacts.csv"
$Database = "xDB"
$OU = "XUnit/Test"
#$Password = (Get-Credential).Password
$Password = ConvertTo-SecureString "P@ssWord1" -AsPlainText -Force

Import-Csv $path | ForEach-Object   {

    $FirstName = $_."FirstName"
    $LastName = $_."LastName"
    $Alias = $_."Alias"

    $UserPrincipalName = $Alias # +xdomain.com"
    $OtherEmail = $FirstName +"."+ $LastName + "@xdomain.com"
    $DisplayName = $LastName+", "+$FirstName

    New-Mailbox -Alias $Alias `
                -Name $Alias `
                -FirstName $FirstName `
                -LastName $LastName `
                -DisplayName $DisplayName `
                -SamAccountName $Alias  `
                -UserPrincipalName $UserPrincipalName `
                -Database $Database `
                -OrganizationalUnit $OU `
                -Password $Password `
                -ResetPasswordOnNextLogon $false

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.