Create Room Mailbox in Exchange 2010 using Powershell

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.

July 20th, 2011 3:24am

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
}

 

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2011 12:35pm

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"

July 21st, 2011 8:25pm

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

Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2011 5:45am

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.
October 4th, 2013 9:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics