How to Delete the First Database and Move the System Mailboxes

When you try to delete the Default Mailbox Database(created with 1st installation of the Mailbox Role), you receive the error below:

“This mailbox database contains one or more mailboxes or arbitration mailboxes. Before you can remove this mailbox database, you must disable, move or remove user mailboxes and move arbitration mailboxes.”

The First database contains the SystemMailboxes which are the Arbitration mailbox(es).

We have to move these system mailboxes to another database before of remove the Default Database.

1. Find the Arbitration Mailbox using the Exchange MAnagement Shell (EMS):

Get-Mailbox -Arbitration | Where {$_.Name -like "SystemMailbox*" } | ft –wrap, name, alias, database

2. Now create a new move request in order to move the system mailboxes to another mailbox database:

New-MoveRequest -Identity "SystemMailbox{1f05a927-32d1-4e19-8ea5-67eba859f541-yourGUID}" -TargetDatabase "dbxxxx"

3. Verify whether the move request completed:

Get-MoveRequest

4. Now remove the move request

Remove-MoveRequest -Identity "the name of the request like Microsoft Exchange Approval Assistant"

PowerShell – Disconnected mailboxes are not yet marked as disconnected

Use the Clean-MailboxDatabase cmdlet to scan the Active Directory directory service for disconnected mailboxes that are not yet marked as disconnected in the Microsoft Exchange store and update the status of those mailboxes in the Exchange store.
This cmdlet is not able to update the Exchange store unless the Microsoft Exchange Information Store service is running and the database is mounted.

Run from exchange management shell:

$mailboxDatabase = Get-MailboxDatabase

foreach ($cont in $mailboxDatabase){
	clean-MailboxDatabase -Identity $cont.Name
}

From remote or normal Powershell window:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
	$mailboxDatabase = Get-MailboxDatabase	
	foreach ($cont in $mailboxDatabase){
		clean-MailboxDatabase -Identity $cont.Name
	}
Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

-Pouyan

PowerShell – Check if email address exists

You can use -ANR to search using Ambiguous Name Resolution (so you can type their first, last, username, etc), but while ANR will match a user’s primary email address, it will not match their other SMTP aliases. ANR can return multiple matches (so ensure your code handles this case).

For email address:

get-mailbox -Anr user@domain.com

For public folder email address:

Get-MailPublicFolder -Anr user@domain.com

– Pouyan

PowerShell – Environment variables

When working with PowerShell I’m searching for the same variables over and over again. Every time when I found them again I think the same “Oh yeah, I knew that!”. To minimize my search next time I thought about writing it down.

First question, how do I use these variables? This is pretty straightforward.

$Env:username

Second question, which environment variables can I use? Use the following cmdlet:

Get-Item Env: | sort Name

Name                           Value                                                                                      
----                           -----                                                                                      
COMPUTERNAME                   <computername>                                                                              
HOMEPATH                       Userssa-sp2010-Install                                                                   
LOCALAPPDATA                   C:Userssa-sp2010-InstallAppDataLocal                                                   
PSModulePath                   D:SPInstallSPModule;D:SPInstallSPModule;C:Userssa-sp2010-InstallDocumentsWindows...
PROCESSOR_ARCHITECTURE         AMD64                                                                                      
CommonProgramW6432             C:Program FilesCommon Files                                                              
CommonProgramFiles(x86)        C:Program Files (x86)Common Files                                                        
ProgramFiles(x86)              C:Program Files (x86)                                                                     
PROCESSOR_LEVEL                6                                                                                          
windows_tracing_flags          3                                                                                          
USERNAME                       sa-sp2010-Install                                                                          
HOMEDRIVE                      C:                                                                                         
USERPROFILE                    C:Userssa-sp2010-Install                                                                 
SystemRoot                     C:Windows                                                                                 
TEMP                           C:UsersSA-SP2~1AppDataLocalTemp                                                       
PUBLIC                         C:UsersPublic                                                                            
ALLUSERSPROFILE                C:ProgramData                                                                             
APPDATA                        C:Userssa-sp2010-InstallAppDataRoaming                                                 
ProgramData                    C:ProgramData                                                                             
PATHEXT                        .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC                                      
OS                             Windows_NT                                                                                 
CommonProgramFiles             C:Program FilesCommon Files                                                              
PROCESSOR_IDENTIFIER           Intel64 Family 6 Model 23 Stepping 10, GenuineIntel                                        
ComSpec                        C:Windowssystem32cmd.exe                                                                
SystemDrive                    C:                                                                                         
PROCESSOR_REVISION             170a                                                                                       
ProgramFiles                   C:Program Files                                                                           
NUMBER_OF_PROCESSORS           2                                                                                          
windows_tracing_logfile        C:BVTBinTestsinstallpackagecsilogfile.log                                              
TMP                            C:UsersSA-SP2~1AppDataLocalTemp                                                       
ProgramW6432                   C:Program Files                                                                           
Path                           C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPower...
USERDOMAIN                     <DOMAIN>                                                                                      
VS100COMNTOOLS                 C:Program Files (x86)Microsoft Visual Studio 10.0Common7Tools                         
windir                         C:Windows

PowerShell – Get default calendar folder name

I was working on a script for monitoring the permissions of mailbox calendar folders, I had a big problem because its an Multilanguage exchange environment. Some of the mailbox folder names are in EN and some are in Dutch.

So I thought in the first place I can get the regional setting of the mailbox and based on that I can decide if it’s a Dutch or EN folder (Calendar or Agenda). But now I found out that some mailboxes got Dutch regional and EN folder names and vice versa.

This is how you can get the default calendar folder without checking the regional or language properties.

Get-mailbox | Get-MailboxFolderStatistics -FolderScope calendar | sort-object Name |ft Identity,Name