Block Activation of Database Copies on an Exchange Server

Scenario:  We need to block database copies on a server from Activation as these servers are being worked on.  Activation is the process of changing a mailbox database copy from a passive copy to an active copy. Activation occurs automatically by the system as part of a database or server failover operation, and it can be performed manually by an administrator as part of a database or server switchover operation. Blocking a database for activation prevents it from becoming the active copy during a database or server failover.

Run the following command to block activation:

For a single server:  
Set-MailboxServer -identity MBX1 -DatabaseCopyAutoActivationPolicy Blocked

For multiple Servers (One liner)
Get-MailboxServer MBX* | Set-MailboxServer -DatabaseCopyAutoActivationPolicy Blocked

Run the following command to unblock activation:

For a single server:  
Set-MailboxServer -identity MBX1 -DatabaseCopyAutoActivationPolicy Unrestricted

For multiple Servers (One liner)
Get-MailboxServer MBX* | Set-MailboxServer -DatabaseCopyAutoActivationPolicy Unrestricted



Reference

Cant delete message in OWA.
Error: Access is denied.
Solution: Insure EWS is enabled on mailbox

In Exchange Powershell run
         get-casmailbox mailboxname |select ewsenabled
if       EwsEnabled                 : False

then enable by running the following command.
         set-casmailbox mailboxname -ewsenabled $true

Removing Bulk Exchange Mailboxes via Powershell

Scenario:  You have a list of mailboxes that you wish to remove in bulk.

Resolution:  We will use the Remove-Mailbox command-let in order to perform this task.  We will remove it via a loop by reading in a CSV file with the mailboxes.  Note:  The Remove-Mailbox will disable the mailbox and delete the AD account.  If you wish to leave the AD Account but only disable the mailbox, use the Disable-Mailbox instead.

Create a CSV file with the names of the mailboxes
  1. Open Notepad
  2. On the first line, type in name
  3. On the second line and down, paste the mailbox names (one mailbox per line).
  4. Save it as Mailboxes.csv to a location you will remember

Import the CSV into a Exchange Variable
  1. Open Exchange Management Shell
  2. Type in the following: (Make sure to use the .csv file path from above)
       $mailboxes = Import-Csv ‘C:mailboxes.csv’
  3.  Verify that your Exchange Variable has content by typing in:
       $mailboxes

Remove the Mailboxes via a loop in Exchange Management Shell.
  1. Type in the following:
       $mailboxes | %{Remove-mailbox $_.name -confirm:$false }
  2. The Mailboxes and AD objects are now removed.

Alternate Methods:

1. Remove a Single Mailbox:    
     Remove-Mailbox jdoe1 -confirm:$false
2. Remove multiple mailboxes that follow a pattern in the mailbox name quickly:
     Get-mailbox jdoe* | Remove-mailbox -confirm $false

     

Gathering Mailbox Counts in Exchange

Scenario:  You need to gather Mailbox Counts in your Exchange Environment.  You need to gather these types of counts: Total Mailboxes in your Exchange Organization, Total Mailboxes per Server, and/or Total Mailboxes per Database.

Run the following:
1. Total Mailboxes in the Exchange Organization
(Get-mailbox -resultsize unlimited).count

2. Total Mailboxes per Mailbox Server
Get-Mailbox -resultsize unlimited | Group-Object -Property:ServerName | Select-Object Name,Count

3. Total Mailboxes per Database
Get-Mailbox -resultsize unlimited | Group-Object -Property:Database | Select-Object Name,Count

If you know specific information for the server or database,  you can run the following:

Server:  (Get-MailboxServer MBX01| Get-mailbox -resultsize unlimited).count
Database:  (Get-MailboxDatabase DB01 | Get-mailbox -resultsize unlimited).count

Users Mailbox is still quarantined after it should have been released automatically. Manually remove the quarantine.

scenario: User’s mailbox was quarantined and couldn’t access email via outlook, mobile device or OWA. User’s mailbox was repaired using this powershell command:
New-MailboxRepairRequest -mailbox testmbox -corruptiontype Aggregatecounts,searchfolder,provisionedfolder,folder
view
To check to see if the repair request has completed, 
  1. Navigate to the Application Log in the Event Viewer:
  2. Filter the Log by:
      a. Event Sources:  MSExchangeIS Mailbox Store
      b. Include these Event IDs for the Repair Request: 10044,10045,01146,10047,10048,10049,10050,10051,10059,10062.
In Exchange 2010, the quarantined mailbox should have been released automatically after 6 hours. However, it was still quarantined after 15 hours.

Resolution: 
After verifying the mailbox repair completed successfully, perform the following:
1. Delete the quarantined mailbox GUID from the registry on the server:  HKLMSYSTEMCURRENTCONTROLSETSERVICESMSEXCHANGEIS<SERVERNAME>PRIVATE-(DB GUID)QUARANTINEDMAILBOXES(MAILBOX GUID)
2. Dismount and Re-mount the database. 
The mailbox was now released from Quarantine

You can’t search for admin audit log entries because the arbitration mailbox for the organization is located on a server that doesn’t have Exchange 2013 installed.

Issue: You can’t search for admin audit log entries because the arbitration mailbox
‘SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}’ for the organization ” is located on a server that doesn’t have Exchange 2013 installed. The mailbox must be moved to an Exchange 2013 server before you can search for admin audit log entries.
Resolution: Move arbitration mailbox to Exchange 2013
Get-Mailbox -Arbitration -Identity “SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}” | New-MoveRequest -TargetDatabase <name of Exchange 2013 database>

Clear all completed Exchange Mailbox Move Requests in bulk

 In Exchange Power Shell, run one of the following:
The Variable Method:

$move = get-MoveRequest | Where {$_.Status –eq ‘completed’}
 Foreach($m in $move){Remove-MoveRequest $m –Confirm:$false}
Or
The One Liner:
get-MoveRequest | Where {$_.Status –eq ‘completed’} | Remove-moverequest -confirm:$false

Exchange Script to combine output from multiple commands into a single CSV file.

Scenario:  You want to combine information from the output of different Exchange Shell commands into a single CSV file. The three commands I am going to combine are below.

get-user     (This holds user specific info)
get-mailbox      (This holds mailbox specific info)
get-mailboxstatistics      (this holds mailbox statistics specific info)

Script:

$mailboxes = get-mailbox -resultsize unlimited | Where Database -like “EXCHDB*”
$mailboxes = $mailboxes | Sort alias

$mailboxes | Foreach-Object{
    $user = Get-User $_.name
    $mbx = Get-Mailbox $_.name
    $mbxstat = Get-MailboxStatistics $_.name
    Write-Host $user

    New-Object -TypeName PSObject -Property @{
        FirstName = $user.FirstName
        LastName = $user.LastName
DisplayName = $user.DisplayName
Title = $user.title
Department = $user.Department
Office = $user.Office
Manager = $user.manager
Alias = $mbx.Alias
Database = $mbx.database
Servername = $mbx.servername
OrganizationalUnit = $mbx.organizationalunit
TotalItemSize = $mbxstat.totalitemsize
TotalItemSizeInMB = $mbxstat | Select {$_.TotalItemSize.Value.ToMB()}
PrimarySMTPAddress = $mbx.primarysmtpaddress

    }
} | Export-csv C:outputMailboxAndUserInfo.csv

Prioritizing Move Requests in Exchange

Scenario:  You want to submit a move request with a higher priority over other pending move requests that are currently queued.  

Solution:  In Exchange Powershell, submit the move request with the -priority parameter.  The accepted values of the parameter are below.
Example:  New-moverequest jdoe1 -targetdatabase DB04 -priority High.
Accepted Values for -Priority Parameter:
Exchange 2010 SP2:  normal,high
Exchange 2013:  lowest, low, normal, high, highest
Notes:
1. By Default, all move requests have a Normal Priority.  
2. MRS will not respect an altered priority unless a move request is halted with the Suspend-MoveRequest cmdlet and then resumed with the Resume-MoveRequest cmdlet.
3. MRS does not halt processing normal-priority move requests when a high-priority mailbox move is initiated. The only time when priority is used is when MRS selects the next move request to process.
4. When MRS looks for new move requests that are waiting to be processed, it first sorts the requests by priority and then by LastUpdatedTimeStamp (a field indicating the last time that the move request was processed by MRS). High priority move requests are therefore selected by MRS before normal-priority move requests. The request priority is included in the msExchMailboxMoveFlags attribute.

Check ExSetup.exe file version information on all Exchange servers remotely

To check ExSetup.exe file version information on all Exchange servers remotely, use below one-liner.

Get-ExchangeServer | Sort-Object Name | ForEach{ Invoke-Command -ComputerName $_.Name -ScriptBlock { Get-Command ExSetup.exe | ForEach{$_.FileVersionInfo } } } | Format-Table -Auto