locked
Adding email addresses via PowerShell using a CSV RRS feed

  • Question

  • Hi,

    Please forgive me if this is in the wrong forum - this is my first post.

    I am trying write a PowerShell script to change email addresses on a test user in our organisation (with a view of making live changes). I am using a CSV as an input file (names have been changed to protect the innocent):

    Users.csv:
    PIN,TargetAddress,FirstName,LastName
    09999,Jack.Bauer@aa.bb.com,Jack,Bauer

    PowerShell script 1:
    $Domains = "@aaa.aaa.com" , "@bbb.bbb.com"
    $Users = Import-Csv .\users.csv
    foreach ($User in $Users)

    {
    Set-Mailbox $User.PIN -EmailAddressPolicyEnabled $false
    Set-Mailbox $User.PIN -EmailAddresses SMTP:$User.FirstName +"." $User.LastName $Domains[0]
    }

    I am only trying it for the first domain, and if it works, I will then be adding more.  However, this is not working.

    So I tried this:

    PowerShell script 2:
    $Domain_a = "@aaa.aaa.com"
    $Domain_b = "@bbb.bbb.com"

    $Users = Import-Csv .\users.csv
    foreach ($User in $Users)
    {
    $Emailaddress_a = $User.FirstName +"." +$User.Lastname +$Domain_a
    Set-Mailbox $User.PIN -EmailAddressPolicyEnabled $false
    Set-Mailbox $User.PIN -EmailAddresses SMTP:$Emailaddress_a
    }

    And get the error:

    WARNING: The command completed successfully but no settings of '<domain>/OU/Users/09999' have been modified.

    I cannot find anything on the Internet which does this kind of thing. Please can someone point me in the right direction?  Which is the easiest way to do this?  

    Kind regards,

    Rob Hughes.


    Monday, August 12, 2013 1:57 PM

Answers

  • Sorry.  I am using Exchange 2010 SP1.
    • Marked as answer by R0b Hughes Monday, August 12, 2013 2:38 PM
    Monday, August 12, 2013 2:11 PM

All replies