AutomaShell

  • TwitterTwitter
  • LinkedInLinkedIn
  • RSS FeedRSS Feed
  • Home
  • About
  • Contact
  • Troy
  • December 4, 2012
  • 2

Enable Exchange 2010 Online Archive in a mixed environment (Part 1: By OU)

  • Part 2:  Enable Exchange 2010 Online Archive in a mixed environment by Database
  • Part 3: Enable Exchange 2010 Online Archive in a mixed environment by CSV
  • Part 4: Conclusion (all wrapped up)

Hello! Today I am going to show you how to enable the Exchange 2010 online archive in a mixed (2007/2010) environment, by OU. Long title, I know! Here is what we’re working with..

  • Mixed environment
  • Enable based on OU
  • Split online archives amongst 4 different databases

http://thelittersitter.com/hour-long-dog-park-trips-for-high-energy-pups/ What it does

This function will get users from a specific OU, ensure they are Exchange 2010 users, and enable the online archive while spreading the users across four seperate databases.

Sundargarh What you need and need to know

  • No special considerations for this!

buy Aurogra india Learn it

As in previous topics, we will use 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
9
10
# Domain controller FQDN
$dc = "dc.domain.local"
# Exchange FQDN
$exchangefqdn = "exch.domain.local"
# Online Archive databases
$databases = "DB1", "DB2", "DB3", "DB4"
# OU of users you want to enable
$ou = "ou=Users,ou=Location,dc=domain,dc=local"
# 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
15
16
17
18
19
20
21
#Enable online Archive by OU
function EnableOnlineArchiveOU {
$count = 0
# Get users in specific OU
$users = Get-ADUser -filter * -SearchBase "$ou" | Sort Name
 
foreach($user in $users) {
# Get mailbox based on the users full name
$mailbox = Get-Mailbox $user.name
 
# Is this user on Exchange 2010?
if($mailbox.ExchangeVersion -like "0.10 (14.0.100.0)") {
# Enable the mailbox. We take a database from the $databases array, and select the next database based on $count
enable-mailbox $mailbox.alias -Archive -ArchiveDatabase $databases[$count]
$count++
 
# When $count reaches the number of databases in your array, reset $count to 0
if($count -eq $databases.count) { $count = 0; }
}
}
}

Cabimas I hope this post is useful to you, and thank you for reading.

Download ZIP

[wpdm_file id=2]

http://pwgmarketing.com/?tag=small-business-marketing 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
55
56
57
58
59
60
61
62
63
########################################
# Enable Online Archive by OU
# 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"
# OU of users you want to enable
$ou = "ou=Users,ou=Location,dc=domain,dc=local"
# 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 OU
function EnableOnlineArchiveOU {
$count = 0
# Get users in specific OU
$users = Get-ADUser -filter * -SearchBase "$ou" | Sort Name
 
foreach($user in $users) {
# Get mailbox based on the users full name
$mailbox = Get-Mailbox $user.name
 
# Is this user on Exchange 2010?
if($mailbox.ExchangeVersion -like "$exchangeversion") {
# Enable the mailbox. We take a database from the $databases array, and select the next database based on $count
enable-mailbox $mailbox.alias -Archive -ArchiveDatabase $databases[$count]
$count++
 
# When $count reaches the number of databases in your array, reset $count to 0
if($count -eq $databases.count) { $count = 0; }
}
}
}
 
EnableOnlineArchiveOU

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