Archive for Mailbox Management

Adding permissions in a cross-forest migration

This week I was working on a cross-forest migration, and instead of using linked mailboxes to set things up and moving mailboxes, I ended up using the CodeTwo migration tool. In that scenario I had live accounts in both forests, and I wanted to allow the users to continue to use their accounts in the original forest to access their mailboxes in the new forest.

To do this, I needed to use the Add-MailboxPermission command on each mailbox, giving their account in the other forest full access. Here’s what I ended up doing:

foreach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) { Add-MailboxPermission -identity "$($Mailbox.Name)" -AccessRights FullAccess -User "olddomain\$($Mailbox.Alias)" }

Exchange 2007 Hosted Exchange Project

This script was part of a test project I was involved with back in 2009 setting up a hosted exchange environment.  The project was scrapped by the people paying the bills before it ever went live, partly because 2010 was about to come out, partly because they finally started to believe me about how much it was going to cost to do it right.  Either way these are the hosted client setup scripts that I built for creating new hosting clients as well as creating new users for those clients. Read more

Mail Disable Public Folders by Script

A customers sever turned out to have about 200 mail enabled public folders, where only a small handful needed to be mail enabled. The folders that needed to remain mail enabled were listed in the Switch statement, and all other folders were disabled by the script.

$PFList = Get-PublicFolder -Recurse

foreach($PF in $PFList) {

	$Folder = $

	$Process = Switch ($Folder)
	 #"IPM_SUBTREE" { $False }
	 "* Admin Inbox" { $False }
	 "* Sales Inbox" { $False }
	 "* Info Inbox" { $False }
	 "* Returns Inbox" { $False }
	 Default { $True }

    If ($Process -eq $True) {
        #write-host "Mail Disableing " $PF.Identity
        Disable-MailPublicFolder -Identity $PF.Identity -Confirm:$False


Bulk Import from GMail (or any IMAP server) to Exchange

This command appears to have been removed in 2013, but it’s one that is worth documenting anyway since it may be worth spinning up a 2007-2010 server to use it if you find yourself needing to migrate off that mistake someone previously made by moving everyone to Google apps, and back to Exchange.

CSV Columns:

Read more

Bulk Rewrite of Display Name

A customer wanted to identify their employees by department when they were emailing people to ensure that people knew who they were dealing with, ex Sales, Finance, Legal Etc.

This script will import a CSV file with a list of existing usernames and prepend the title “Sales-” to their display name. Read more

List all Disconnected Mailboxes with timestamp

I came across a situation where someone was messing around in AD and had accidentally deleted an account, Realizing their mistake they re-created with the same password it thinking it would just re-connect to the mailbox and the user would be fine.  By the time they called me they had deleted and re-created the account a number of times.  I had to identify the correct mailbox to reconnect to the user account, out of 4-5 versions all with the same exact name.

This command shows all disconnected mailboxes as well as the date the corresponding user account was deleted, and leaving the mailbox disconnected. The timestamp allowed me to connect the correct mailbox to the account without having to guess at anything.

get-mailboxserver | get-mailboxstatistics | where { $_.DisconnectDate } | fl DisplayName, DisconnectDate

Refresh Disconnected Mailboxes

If you ever need to force a refresh of the disconnected mailboxes on Exchange, the following command will do this for all mailbox databases.

Get-Mailboxdatabase | Clean-MailboxDatabase

I recently had to do this because one of my clients recently created a mailbox for a new employee, but didn’t realize until a few days later they had misspelled the employee’s last name, but not before they had generated a bit of internal email for the new hire.   Since so many things like logon scripts and folder redirections rely on the username, I could have fixed the display name, but would have had to leave the username unchanged and mis-spelled or risk breaking other things that I just didn’t want to deal with.  I directed the client to delete the old account and create a new one, but not create a mailbox this time.  After forcing the refresh I was able to easily reconnect the mailbox to the new correctly spelled user account, without the user loosing any data from their mailbox, or the need to export it to a PST and re-import it.