AutomaShell

  • TwitterTwitter
  • LinkedInLinkedIn
  • RSS FeedRSS Feed
  • Home
  • About
  • Contact
  • Troy
  • April 26, 2013
  • 1

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

vigilantly 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.

http://thebandchoice.com/wedding-bands-hertfordshire/ 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

Exchange Server · PowerShell

© Copyright 2012-2018 AutomaShell. Contact me if you have any questions.

  • TwitterTwitter
  • LinkedInLinkedIn
  • RSS FeedRSS Feed
  • Tabs

    • Recent Posts
    • Most Popular
    • Comments
    • Nutanix AOS 5.10 & Prism Central 5.10 releasedNovember 26, 2018
    • Nest VMware ESXi on Nutanix AHVSeptember 18, 2018
    • Nutanix Calm – AWS Setup & Example App DeploymentAugust 15, 2018
    • Nutanix: Add Unprotected VMs to Protection DomainJune 7, 2018
    • Deploy VMware VM’s with PowerCLIOctober 23, 2012
    • Enable Exchange 2010 Online Archive in a mixed environment (Part 1: By OU)December 4, 2012
    • User Termination (Part 2)June 6, 2013
    • Search Active Directory with PowerShell (LDAP)April 29, 2013
    • Rob Duff on:Search Active Directory with PowerShell (LDAP)
    • sean on:Deploy VMware VM’s with PowerCLI
    • Troy on:Deploy VMware VM’s with PowerCLI
    • Niklas Ilves on:Deploy VMware VM’s with PowerCLI
  • Categories

    • AWS
    • Calm
    • Exchange Server
    • General
    • Nutanix
    • PowerCLI
    • PowerShell
    • Uncategorized
    • VMware
    • Windows Server