After a Database Reseed, the following error is displayed: Error: Unable to delete logs at ‘C:DB01Logs’. The database has been seeded successfully. If any obsolete log files exist, manualy delete them to prevent database divergence.

Scenario:  During a Exchange database reseed, you get the following error when the reseed is finished:

Update-MailboxDatabaseCopy DB01MBX02 -DeleteExistingFiles

A source-side operation failed. Error An error occurred while performing the seed operation. Error: Unable to delete logs at ‘C:DB01Logs’. The database has been seeded successfully. If any obsolete log files exist, manualy delete them to prevent database divergence. Error: System.IO.IOException: The file or directory is corrupted and unreadable.

Resolution:  Format the hard drive and perform the reseed again.

Add a new email address to mailboxes in bulk

This one liner reads a list of user names from a text file, fetches the current set of proxy email addresses, and adds a new “test.com” SMTP email address to each mailbox.

Get-Content Users.txt | Get-Mailbox |% {$_.EmailAddresses.add(“smtp:$($_.SamAccountname)@test.com”); Set-Mailbox -Identity:$_.Identity -EmailAddresses:$_.EmailAddresses}

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

You receive the following error when trying to import a pst file with a large message to an Exchange mailbox.

Error: This mailbox exceeded the maximum number of large items that were specified for this request.
Solution: Raise the -LargeItemLimit size above the default 35mb.

Example:
New-MailboxImportRequest -Mailbox Ben -LargeItemLimit 50 -AcceptLargeDataLoss -FilePath serverben.pst

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