locked
Create Room Mailbox in Exchange 2010 using Powershell RRS feed

  • Question

  • I am new in scripting and wanted to create a PowerShell script for room mailbox creation that will fulfil below requirements:


    1. Take input from a csv file. Input will contain Display Name, Manager name (manager can be any user of any domain from entire forest and it can be like domain\user).
    2. Create a Room Mailbox with Alpha numeric account names but display names can be in alpha. Example: Display Name: “Conference Room US”, Account name: “RoomMailBox8854”.
    3. The numbers used in account name shall be unique and rendom. If I have created a mailbox with RoomMailBox8854 name then next time whenever I run the script It will generate a unique account numbers for the mailbox but the name "RoomMailBox" should be common for every room mailbox.
    4. Manager option should be selected.
    5. After creation should generate a report for the same.
    6. Need Script with or without Error handling.



    • Moved by Alan.Gim Friday, July 22, 2011 1:13 AM Script-related (From:Exchange Software Updates)
    Wednesday, July 20, 2011 12:24 AM

All replies

  • You can use this one and edit it and add the functions you want

     

    $data = Import-Csv .\Rooms.csv

    $password = Read-Host "Enter password" -AsSecureString
        foreach ($row in $data) {
        $Alias = $row.Alias
        $UserPrincipalName = $row.UserPrincipalName
        $Name = $row.DisplayName
               
        New-Mailbox -Database "DB" -Alias $Alias -Name $Name -UserPrincipalName $UserPrincipalName -OrganizationalUnit "domain.local/Rooms" -Password $password -Room
    }

     


    Jonas Andersson | Microsoft Community Contributor Award 2011 | MCITP: EMA 2007/2010 | Blog: http://www.testlabs.se/blog | Follow me on twitter: jonand82
    Thursday, July 21, 2011 9:35 AM
  • Hi Jonas,

    At your place you are correct. But I need something more then creating a room mailbox only. As I have described in my question, I need unique account names also. I can give you a concept for this, As I have less knowledge I can not write accordingly but I have a concept for this.

    "The script will pull the mailbox name from csv and create a rendom and unique account name and search in ad for existing account names if there is no matching account names available then it will create the room mailbox but if it exist then it will add +1 to the new account name and create a log file somewhere in system with account name when it run first time. On the second time it will pull the display name from csv file and check in last log file for account name and will add +1 to the new account name and start searching in ad for the new account name, if there is no account with same name exist then it will create otherwise will add +1 to the new account name. Hope it will help you scripting gigs"

    Thursday, July 21, 2011 5:25 PM
  • Hi,

     

    The cmdltes in Exchange 2010 is similar in Exchange 2007. You may refer to the link below:

     

    Exchange 2007 PowerShell Scripts

    http://social.technet.microsoft.com/wiki/contents/articles/exchange-2007-powershell-scripts.aspx

    Scripting Creation and Configuration of Exchange 2007 Resource Mailboxes

    http://social.technet.microsoft.com/Forums/en-GB/ITCG/thread/e47f82fd-4e53-4de9-bad8-1995a672f520


    Fiona
    Friday, July 22, 2011 2:45 AM
  • You could create the random number (get-random), then do a get-mailbox to see if you get an empty result set (error trapping/handling), loop through that until you get a random number that hasn't been used, and then proceed with your resource account creation.
    Friday, October 4, 2013 1:53 PM