Exchange Tasks

With this script you will be able to do the most basic function of mailbox moving in your domain.

 

You can:

  • Mail Enable a User
  • Mail Enable all the users in an OU
  • Move all Legacy mailboxes to Exchange 2007
  • Move all mailboxes by OU name to Exchange 2007

##########################

# Created By Assaf Miron #

##########################


Write-Host "Choose a Task : "

Write-Host " [1] : Mail Enable a User"

Write-Host " [2] : Mail Enable all Users in an OU"

Write-Host " [3] : Move All Legacy Mailboxes to Exchange 2007"

Write-Host " [4] : Move Mailboxes By OU Name to Exchange 2007"

Write-Host ""

$Choose = Read-Host

Switch ($Choose) {

1 {

$UserName = Read-Host "Enter the User or Group Alias you want to create a Mailbox to"

$DBName = Read-Host "Enter the DB Name you want to create the Mailbox in"

Write-Host "Mail Enabling User : "$UserName" to DB :"$DBName

Enable-Mailbox -Identity $UserName -Database $DBName

  }


2 {

$OU = Read-Host "Enter the OU Name you want to create the Mailboxes in (Only OU's Under <OU Configuration> OU)"

$DBName = Read-Host "Enter the DB Name you want to create the Mailboxes in"

$OU = 'TestEnv2007.com/<OU>/'+$OU

Write-Host "Moving all Mailboxes in OU : "$OU" ,to DB "$DBName

Get-User -OrganizationalUnit $OU | Enable-Mailbox -Database $DBname

  }


3 {

$DBName = Read-Host "Enter the DB Name you want to create the Mailboxes in"

Write-Host "Moving all Mailboxes to DB "+$DBName

Get-Recipient | Where { $_.RecipientTypeDetails -eq "LegacyMailbox"} | Move-Mailbox -TargetDatabase $DBName -MaxThreads 16

  }


4 {

$OU = Read-Host "Enter the OU Name you want to create the Mailboxes in (Only OU's Under <OU> OU)"

$DBName = Read-Host "Enter the DB Name you want to create the Mailboxes in"

$OU = 'TestEnv2007.com/<OU>/'+$OU

Write-Host "Moving all Mail Boxes in OU : "$OU" ,to DB "$DBName

Get-Mailbox -OrganizationalUnit $OU | Move-Mailbox -TargetDatabase $DBname -MaxThreads 16

  }

Comments