Thursday, February 16, 2012

Exchange 2010 enable mailbox for multiple distribution groups


You can generate mailboxes for multiple distribution groups at the same time, the group names will be read from a text file. To do this:

Open Exchange Management Shell with Administrator rights, then:

Get-Content <OU_LIST_FILE> | Foreach-Object {Enable-DistributionGroup -Identity "$_" -Alias "$_" -DisplayName "$_" -PrimarySMTPAddress "$_@<FQDN_NAME>"}


Example:

Get-Content C:\oulist.txt | Foreach-Object {Enable-DistributionGroup -Identity "$_" -Alias "$_" -DisplayName "$_" -PrimarySMTPAddress "$_@ibs-t.hu"}

-> This will read OU names from the file 'C:\oulist.txt' and create the distribution groups defined in the file, in the domain 'ibs-t.hu'.
It's a simple text file, with the OU names under each other:

---BEGIN FILE---
grpGazd2006
grpGazd2007
---END OF FILE---

Output sample:

Name                          DisplayName                   GroupType                     PrimarySmtpAddress
----                          -----------                   ---------                     ------------------
grpGazd2006                   grpGazd2006                   Universal, SecurityEnabled    grpGazd2006@ibs-t.hu
grpGazd2007                   grpGazd2007                   Universal, SecurityEnabled    grpGazd2007@ibs-t.hu

Exchange 2010 enable mailbox for distribution group


Here's how to generate mailbox for a distribution group:

Open Exchange Management Shell with Administrator rights, then:

Enable-DistributionGroup -Identity "<GROUP_NAME>" -Alias "<GROUP_NAME>" -DisplayName "<CAN BE CUSTOM>" -PrimarySMTPAddress "<DESIRED E-MAIL ADDRESS>"


Example:

Enable-DistributionGroup -Identity "grpBattm2007" -Alias "grpBattm2007" -DisplayName "Battm2007" -PrimarySMTPAddress "grpBattm2007@ibs-t.hu"

-> This will create a distribution group named grpBattm2007 from a group named grpBattm2007, and set the display name of the group to Battm2007, with e-mail address of grpBattm2007@ibs-t.hu
The DisplayName parameter can be omitted, in this case the display name will be the same as the group name.

Output sample:

Name                          DisplayName                   GroupType                     PrimarySmtpAddress
----                          -----------                   ---------                     ------------------
grpBattm2007                  Battm2007                     Universal, SecurityEnabled    grpBattm2007@ibs-t.hu

Exchange 2010 enable mailbox for users in an OU


Use this command to generate mailboxes for all user accounts in a specified organizational unit:


Open Exchange Management Shell with Administrator rights, then:


Get-User -OrganizationalUnit <OU_NAME> | where-object {$_.RecipientType -eq "User"} | Enable-Mailbox -Database "<DATABASE_NAME>" | get-mailbox | select name,windowsemailaddress,database


Example:

Get-User -OrganizationalUnit Baibr2010 | where-object {$_.RecipientType -eq "User"} | Enable-Mailbox -Database "Student Mailbox Store" | get-mailbox | select name,windowsemailaddress,database

-> This will create mailboxes for all users in an OU named Baibr2010, and in the mailbox database Student Mailbox Store and domain ibs-t.hu

Output sample:

Name                                    WindowsEmailAddress                     Database
----                                    -------------------                     --------
Stiller David                           DSTILLER@ibs-t.hu                       Student Mailbox Store
Bayarsaikhan Oyunjargal                 OBAYARSAIKH@ibs-t.hu                    Student Mailbox Store
Puiu Roman                              RPUIU@ibs-t.hu                          Student Mailbox Store
Lajos Adrian                            ALAJOS@ibs-t.hu                         Student Mailbox Store
Raab Renata Rozsa                       RRAAB@ibs-t.hu                          Student Mailbox Store
Lang Lorand                             LOLANG@ibs-t.hu                         Student Mailbox Store
Lazar Zsolt                             ZSLAZAR@ibs-t.hu                        Student Mailbox Store
Li Cong                                 CLI@ibs-t.hu                            Student Mailbox Store
Tran Ba Duy Phuong                      BTRAN@ibs-t.hu                          Student Mailbox Store

Exchange 2010 move System Mailboxes to new database and remove the default mailbox database



After you’ve installed a new Exchange 2010 environment and you try to delete the first automatically created mailbox database, you’ll receive an error message, saying it still contains mailboxes.
You cannot remove the database, because there are still some hidden, system mailboxes in it, although it looks empty.
You will need to move these system mailboxes to a new database before this default database can be deleted.


Here are the steps to follow:

Open Exchange Management Shell with Administrator rights, then:

1. List the arbitration (system) mailboxes in the database you want to remove (the wrap parameter must be also specified, otherwise the full GUID name won't be displayed!):

Get-Mailbox -Database "<DEFAULT_DATABASE_NAME>" -Arbitration | ft -wrap -auto


Example:

Get-Mailbox -Database "Mailbox Database 0019304662" -Arbitration | ft -wrap -auto

Output sample (sorry it looks disorted in the blog):

Name                                                Alias                                               ServerName Proh
                                                                                                                   ibit
                                                                                                                   Send
                                                                                                                   Quot
                                                                                                                   a
----                                                -----                                               ---------- ----
SystemMailbox{1f05a927-6cae-4b43-9e78-20b3905e51b9} SystemMailbox{1f05a927-6cae-4b43-9e78-20b3905e51b9} mars       unli
                                                                                                                   mite
                                                                                                                   d
SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9} SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9} mars       unli
                                                                                                                   mite
                                                                                                                   d
FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042 FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042 mars       1 MB
                                                                                                                    (1,
                                                                                                                   048,
                                                                                                                   576
                                                                                                                   byte
                                                                                                                   s)

-> This means there are still 3 system mailboxes inside the first mailbox database (created by Exchange setup, called 'Mailbox Database 0019304662'), that we want to remove on the server named MARS


2. Move each system mailboxes to the new database, copy and paste their identity name from the previous command:

New-MoveRequest -Identity "<SYSTEM_MAILBOX_NAME>" -TargetDatabase "<TARGET_DATABASE_NAME>"


Example:

New-MoveRequest -Identity "SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}" -TargetDatabase "Employee Mailbox Store"

Output sample (sorry it looks disorted in the blog):

DisplayName               Status                    TotalMailboxSize          TotalArchiveSize         PercentComplete
-----------               ------                    ----------------          ----------------         ---------------
Microsoft Exchange        Queued                    80.16 KB (82,081 bytes)                            0


-> In this example, our target mailbox database is called 'Employee Mailbox Store'


3. Don't remove the default (in our case 'Mailbox Database 0019304662') mailbox database yet, first remove the move requests for these mailboxes from the Management Console.
If you forget this step, you will have to manually remove these corrupted move requests from the Management Shell, otherwise no move requests can be displayed in the Management Console.

Use this command to remove requests from the Management Console:

Remove-MoveRequest -Identity "<SYSTEM_MAILBOX_NAME>"


Example:

Remove-MoveRequest -Identity "SystemMailbox{1f05a927-6cae-4b43-9e78-20b3905e51b9}"

Output sample:

Confirm
Are you sure you want to perform this action?
Move request 'Microsoft Exchange Approval Assistant' is corrupted or not recognized: Source database for the move
doesn't match. Active Directory value: '(null)'. Move request value: 'Mailbox Database 0019304662'.. Are you sure you
want to remove it?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y

-> Copy and paste the Identity name for the system mailboxes, repeat for each

After the move requests are removed, you can now delete the default mailbox database itself.
It will still leave the .EDB file in the Exchange directory, you will need to remove it manually.