Enable Exchange ActiveSync on a Mailbox with PowerShell

Exchange 2007 brought some changes to managing mailboxes, most notably, the removal of Exchange tabs from Active Directory. In Exchange 2003, to enable Exchange ActiveSync for a mailbox, you would simply open the ADUC properties for a user, click the Exchange Features tab, click Exchange ActiveSync, and then click Enable.

Today, with Exchange 2007 and Exchange 2010, the function isn’t quite as easily found, but it’s much easier to use. On any machine with the Exchange Management Tools loaded, fire up the Exchange Management Shell (this won’t work in your regular PowerShell terminal) and type the following, replacing “Firstname Lastname” with the user’s first and last name, or their user ID, in quotes.

 Get-Mailbox "Firstname Lastname" Set-CASMailbox -ActiveSyncEnabled $true

Disable/Enable a Mailbox – Change user account while saving mails

Sometimes you have to change a whole account but transfer the mailbox database.

There are two ways to do that :

1 – Creating the new account, creating an export of the mailbox using pst files, importing this pst file into the new mailbox

Using that method, the person which will do that will have all access to the user’s mails, not really secure..

2 (the best one) :

Using this little script 🙂

#Getting all mandatory informations about the old username
$OlduserDatabase=(Get-mailbox $olduser).Database.ToString()
$OlduserDisplayName=(Get-mailbox $olduser).DisplayName.ToString()

#Disabling and cleaning the mailbox/database
Disable-Mailbox $Olduser -confirm:$false
Clean-MailboxDatabase $OlduserDatabase
$domainusername=”$onedomain$newuser”

#Getting the mailboxdatabase of the old user
$disconnectedMailbox=Get-DisconnectedMailbox $OlduserDisplayName
$disconnectedMailbox |
Foreach-Object{
Connect-Mailbox -Identity $_.StoreMailboxIdentity -Database $OlduserDatabase -User $domainusername -Alias $newuser
}
#Here we go !
return “New user $newuser has been succesfully made”