Enable Exchange 2010 Online Archive in a mixed environment (Part 2: By Database)
- Part 1: Enable Exchange 2010 Online Archive in a mixed environment by OU
- Part 3: Enable Exchange 2010 Online Archive in a mixed environment by CSV
- Part 4: Conclusion (all wrapped up)
Today I will show you how to enable the OA by database inside a mixed environment.
- Mixed environment
- Enable based on Database
- Split online archives among 4 different databases
Hwawŏn What it does
This function will get users from a specific database, ensure they are Exchange 2010 users, and enable the online archive while spreading the users across four separate databases.
buy Seroquel cheap without prescription What you need and need to know
- No special considerations for this!
Learn it
ConnectAD and ConnectExchange to load these modules remotely rather than depend on having the tools installed locally.
1 2 3 4 5 6 7 8 9 10 11 12 |
#Connect to Active Directory and load modules function ConnectAD { $session = New-PSSession -ComputerName $dc Invoke-Command -Session $session -ScriptBlock {Import-Module ActiveDirectory} Import-PSSession -Session $session -Module ActiveDirectory } #Connect to Exchange and load modules function ConnectExchange { $exch = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangefqdn/powershell -name Exchange Import-PSSession $exch } |
Load the modules (AD and Exchange), unless they have already been loaded.
1 2 3 4 5 6 7 8 |
#Load modules if(!(Get-PSSession | ?{$_.ComputerName -like "$dc*"}) -and $askoncepersessionmodules -ne 1) { $global:askoncepersessionmodules = 1 cls write-host "Connecting to Active Directory, and Exchange. Please wait..." -f yellow; ConnectAD ConnectExchange } |
We need to set our variables.
1 2 3 4 5 6 7 8 |
# Domain controller FQDN $dc = "dc.domain.local" # Exchange FQDN $exchangefqdn = "exch.domain.local" # Online Archive databases $databases = "DB1", "DB2", "DB3", "DB4" # Your full Exchange version. If you don't know, type (get-mailbox user).ExchangeVersion $exchangeversion = "0.10 (14.0.100.0)" |
We’re now ready to enable the online archive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#Enable online Archive by Database function EnableOnlineArchive { $count = 0 $mbdbs = Get-MailboxDatabase foreach($mbdb in $mbdbs) { $users = get-mailbox -database $mbdb.name foreach($user in $users) { write-host enable-mailbox $user.alias -Archive -ArchiveDatabase $databases[$count] $count++ if($count -eq 4) { $count = 0; } } } } |
I hope this post is useful to you, and thank you for reading.
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
######################################## # Enable Online Archive by DB # Created by Troy Ward ######################################## #Variables # Domain controller FQDN $dc = "dc.domain.local" # Exchange FQDN $exchangefqdn = "exch.domain.local" # Online Archive databases $databases = "DB1", "DB2", "DB3", "DB4" # Your full Exchange version. If you don't know, type (get-mailbox user).ExchangeVersion $exchangeversion = "0.10 (14.0.100.0)" # No more variables #Connect to Active Directory and load modules function ConnectAD { $session = New-PSSession -ComputerName $dc Invoke-Command -Session $session -ScriptBlock {Import-Module ActiveDirectory} Import-PSSession -Session $session -Module ActiveDirectory } #Connect to Exchange and load modules function ConnectExchange { $exch = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangefqdn/powershell -name Exchange Import-PSSession $exch } #Load modules if(!(Get-PSSession | ?{$_.ComputerName -like "$dc*"}) -and $askoncepersessionmodules -ne 1) { $global:askoncepersessionmodules = 1 cls write-host "Connecting to Active Directory, and Exchange. Please wait..." -f yellow; ConnectAD ConnectExchange } #Enable online Archive by Database function EnableOnlineArchive { $count = 0 $mbdbs = Get-MailboxDatabase foreach($mbdb in $mbdbs) { $users = get-mailbox -database $mbdb.name foreach($user in $users) { write-host enable-mailbox $user.alias -Archive -ArchiveDatabase $databases[$count] $count++ if($count -eq 4) { $count = 0; } } } } EnableOnlineArchive |