본문 바로가기
OS/Windows Server

[Windows Server] Exchange Powershell - Enable Mailbox

by Haengsin 2021. 11. 30.
Exchange Server AD Migration - Enable Mailbox

전제

-       진행 전 .csv 파일로 기존 서버의 AD List를 뽑아 Active Directory에 users에 추가.

 

내용

-       Filtering 적용 : User만 진행

-       Archive Dtabase 할당량 20GB, 경고 메시지 19GB 추가

-       200 , 300명 단위로 TEST Dabase 1,2,3 과 TEST Archive Database 1,2,3 Enable 처리.

 

$i=1;
Get-User -OrganizationalUnit "TEST" -Filter "objectclass -like 'user'" | ForEach-Object {
           
           
           if($i -gt 0 -And $i -lt 200 )
           {
                     Enable-Mailbox -identity $_  -Database "TEST Database 1" 
                     Enable-Mailbox -identity $_  -ArchiveDatabase "TEST Archive Database 1"
           
                     $MailBox = @{

                     'Identity' = $_.name
           
                     'PrimarySmtpAddress' = $_.SamAccountName+'@test.com'
                     'EmailAddressPolicyEnabled' = $False
                     'ArchiveQuota' = 20GB
                     'ArchiveWarningQuota' = 19GB     
                     }          

                     Set-Mailbox @Mailbox
           }
           Elseif($i -gt 200 -And $i -lt 400 )
           {
                     Enable-Mailbox -identity $_  -Database "TEST Database 2" 
                     Enable-Mailbox -identity $_  -ArchiveDatabase "TEST Archive Database 2"
           
                     $MailBox = @{

                     'Identity' = $_.name
           
                     'PrimarySmtpAddress' = $_.SamAccountName+'@test.com'
                     'EmailAddressPolicyEnabled' = $False
                     'ArchiveQuota' = 20GB
                     'ArchiveWarningQuota' = 19GB     
                     }          

                     Set-Mailbox @Mailbox
           }
           Elseif($i -gt 400 -And $i -lt 700 )
           {
                     Enable-Mailbox -identity $_  -Database "TEST Database 3" 
                     Enable-Mailbox -identity $_  -ArchiveDatabase "TEST Archive Database 3"
           
                     $MailBox = @{

                     'Identity' = $_.name
           
                     'PrimarySmtpAddress' = $_.SamAccountName+'@test.com'
                     'EmailAddressPolicyEnabled' = $False
                     'ArchiveQuota' = 20GB
                     'ArchiveWarningQuota' = 19GB     
                     }          

                     Set-Mailbox @Mailbox
           }
           
           $i = $i + 1
           
}

 

※ Resource Mailbox List 추출

Get-mailbox  -resultsize unlimited | where-object {$_.ResourceType -eq "room"} | export-Csv -Path "C:\Resource_List.csv"

 

 Resource Mailbox List 추출 (DisplayName만)

Get-mailbox  -resultsize unlimited | where-object {$_.ResourceType -eq "room"} | Select DisplayName | export-Csv -Path "C:\Resource_List2.csv"