locked
Creating bulk multiple ex2007 Mailbox via CSV for Existing AD Accounts RRS feed

  • Question

  • Hi

    I want to create around 1000+ new exchange 2007 mailboxes for existing AD user accounts. Is there a simpler way to do this?

    Script to create mailboxes for users

    $mailbox=import-csv C:\Users\admin-me\Desktop\mail.csv
    foreach ($mailbox in $mailbox) {enable-mailbox -identity $mailbox.identity -database $mailbox.database}

    The above script seems to create the mailboxes but throws up an error due to the enable-mailbox function:

    The term 'enable-mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.

    I also need to create another script or add to above script to set a mailbox retention policy as I have tried below

    $data = import-csv C:\Users\admin-me\Desktop\180.csv
    foreach ($line in $data) {set-mailbox $line.mailboxname -managedfoldermailboxpolicy 'Mailbox retention 180 days' -managedfoldermailboxpolicyallowed -confirm:$false}

    Also need to create a script to prohibit email sending restrictions to 17MB per email, but allow users to receive emails

    Any help on merging all above scripts would be very much appreciated. Or if I have to run three seperate scripts thats fine too for same user base

    Many Thanks for reading



    Tuesday, May 22, 2012 6:10 PM

Answers

  • What creates that csv file in the first place?  Is the selection criteria within AD already?

    You could easily run 

    $userlist = Get-User <some filter criteria>
    $userlist | Enable-Mailbox 
    $userlist | Set-Mailbox -ManagedFolderMailboxPolicy 'Mailbox retention 180 days' -ManagedFolderMailboxPolicyAllowed




    Mike Crowley | MVP
    My Blog -- Planet Technologies

    • Proposed as answer by emma.yoyo Thursday, May 24, 2012 3:08 AM
    • Marked as answer by emma.yoyo Tuesday, May 29, 2012 2:12 AM
    Tuesday, May 22, 2012 11:59 PM
  • Hi Mike

    No worries I found a solution :-) Thanks for your help nevertheless

    Andy

    • Marked as answer by bongonations Tuesday, May 29, 2012 10:11 AM
    Tuesday, May 29, 2012 10:11 AM

All replies

  • What creates that csv file in the first place?  Is the selection criteria within AD already?

    You could easily run 

    $userlist = Get-User <some filter criteria>
    $userlist | Enable-Mailbox 
    $userlist | Set-Mailbox -ManagedFolderMailboxPolicy 'Mailbox retention 180 days' -ManagedFolderMailboxPolicyAllowed




    Mike Crowley | MVP
    My Blog -- Planet Technologies

    • Proposed as answer by emma.yoyo Thursday, May 24, 2012 3:08 AM
    • Marked as answer by emma.yoyo Tuesday, May 29, 2012 2:12 AM
    Tuesday, May 22, 2012 11:59 PM
  • Hi Andrew,

    Any updates?


    Frank Wang

    TechNet Community Support

    Thursday, May 24, 2012 3:08 AM
  • Hi Mike

    Thank you for the reply. I manually populate the CSV file with user IDs that need email accounts.

    Please could you show me a way to combine all three scripts into one script rather than run them seperately?

    The relevant Exchange admin tools are installed. The first script creating mailboxes above works but I get an error coming back

    enable-mailbox: cannot bind parameter 'identity'. Cannot convert value "" to type "microsoft .exchange.configuration.tasks.useridparameter". Error: "The parameter value of this type Microsoft.exchange.configuration.tasks.useridparam eter cannot be empty Parameter name: identity" 

    Thanks

    Andy

    Thursday, May 24, 2012 8:49 AM
  • Yes, I can help combine the code, but you must first tell me what the selection criteria would be.  You're saying you enter 1000 accounts manually into a csv.  That sounds like a horrible afternoon.  :)

    enable-mailbox requires an identity parameter.  This can be passed through the pipeline, but it depend on what your csv looks like, or better yet, what we grab using criteria I asked about above.



    Mike Crowley | MVP
    My Blog -- Planet Technologies

    Thursday, May 24, 2012 4:53 PM
  • Hi Mike

    No worries I found a solution :-) Thanks for your help nevertheless

    Andy

    • Marked as answer by bongonations Tuesday, May 29, 2012 10:11 AM
    Tuesday, May 29, 2012 10:11 AM
  • Hi Mike, 

    Can you please share how to create bulk mailboxes in Exchange 2k7. This is an old customer and still on Ex2k7. But they need to add some 50 users. 

    Regards,

    Tuesday, November 5, 2013 3:42 PM