Manually Purge Log Files from Exchange Database Copies

Purpose:  The purpose of this document is to provide instruction on how to safely purge Exchange Database log files manually after log file buildup on a Exchange Server.  Log files are stored in the logs directly until an Exchange aware Full or Incremental Backup is successfully ran.  Once Exchange is aware that this backup is complete, Exchange will purge the log files.  If a backup has not ran successfully, then log files will continue to be created in the logs directory and the previous log files will still exist, consuming space.  Over time, this will fill up the hard drive where the log files are kept.  This manual purge is done live, meaning the instructions below happen while the Exchange Database remains mounted.  In the instructions below, we are using an Exchange Database DB53 that has 4 Database Copies; 1 Mounted, 3 Healthy.

Overview of the Instructions Below:

1. Capture and isolate the Log Files that will moved and purged into a text file.

2. Using Excel, open that text file and format it. Format meaning remove unwanted rows such as Header/Footer rows and removing log files for dates you wish to not remove.  For Example, I want to remove all the log files EXCEPT the last day or two. **NOTE do not remove the newest log files – give yourself a buffer**.

3. Using Excel, we will formulate the Move-Item and Remove-Item scripts to be ran on each server that holds the database copy.  From one database copy, we will move the log files to another serverstorage location.  From the other 3 database copies, we will purge the log files.  Purging log files is quick, moving log files is a little bit slower.

4. Run the appropriate .ps1 script that will be created on each server that holds a database copy.

Instructions:

Capture and Isolate the Log Files:
1. Determine the LogFilePrefix for the database:
get-mailboxdatabase DB53 | FL LogFilePrefix

2. Determine the Database Copies Status to figure out which copy is mounted, healthy, or other status. Of the Mounted/Healthy Database Copies, choose 1 Database Copy to move the logs that wish to be purged to a storage share and purge the logs on the remaining copies. This ensures a copy of the logs exist in the event of a problem.

Get-mailboxdatabasecopystatus DB53

3. In a command prompt, run the following DIR command. It will put the results into the text file specified.  You will be using the LogFilePrefix you have found in Step1.

dir MBX01e$db53logsE01*.log > C:usersstevedesktopDB53.txt

In Excel, Open the Text File and Format It

4. Open Excel and then Open that Txt File.  Make sure during the Text Import Wizard (when opening the txt file in Excel), the logs are in their own column. I chose fixed width in the Wizard. Click on Finish.

5. Remove the rows that do not contain a log file (Very Beginning Rows and Very Last Rows).

6. Sort the dates (if not sorted already) and remove the rows of the date range that you do not wish to delete. For Example, I want to purge all log files EXCEPT for the last 2 days’ worth.

In Excel, Create the PowerShell Code used to Move/Purge Log Files

7. In Column F (Or the next Open Column) type this formula in and Copy on down to the last row. Note: Cell E2 is the log file name. You may have to change this value if the log file name exists in a different cell.

=”Write-Host “&E2&”; Move-Item E:DB53Logs”&E2&” FileSvr1filesDB53″ 

8. In Column G (or the next Open Column) type this formula in and Copy on down to the last row. Note: Cell E2 is the log file name. You may have to change this value if the log file name exists in a different cell.

=”Write-Host “&E2&”; Remove-Item E:DB53Logs”&E2&” -force”

 9. Copy the Contents out of the Move-Item Column and paste into notepad. Save that notepad file as DB53_move.ps1.  Copy this and run this on the server that has the database copy for you wish to move the log files.

10. Copy the Contents out of the Remove-Item Column and paste into notepad. Save that notepad file as DB53_remove.ps1.  Run this in PowerShell on the servers that have the remaining database copies.

Now you have carefully Moved/Purged the Log Files of that database. You now have bought yourself enough free space on the hard drives to work out your backup issues.

Export Mail into a PST between two dates

Scenario:  You want to export mail from a mailbox into a PST with a filter of between two dates.

Run this command:

New-MailboxExportRequest -ContentFilter {(Received -gt ’01/01/2014′) -and (Received -lt ’04/01/2014′)} -Mailbox “testuser1” -Name testuser1 -FilePath ServerSharetestuser1.pst -baditemlimit 999 -acceptlargedataloss

Exchange Server unexpectedly reboot after CU6 and databases in service down state.

Issue
Exchange Server unexpectedly reboot after CU6 and databases in service down state.
Cause
Based on the dump it looks to be caused by Replication Services Crashing.
Resolution
Database copy status on the server was showing ServiceDown
After sometime it was showing initializing and few mins later again showing ServiceDown
Checked Event ID
Log Name:      Application
Source:        MSExchange Common
Date:          
Event ID:      4999
Task Category: General
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      
Description:
Watson report about to be sent for process id: 41108, with parameters: E12IIS, c-RTL-AMD64, 15.00.0995.029, msexchangerepl, M.Exchange.Common, M.E.C.H.DatabaseFailureItem.Parse, System.ArgumentOutOfRangeException, fe19, 15.00.0995.012.
ErrorReportingEnabled: True
Log Name:      Application
Source:        Windows Error Reporting
Date:         
Event ID:      1001
Task Category: None
Level:         Information
Keywords:      Classic
User:          N/A
Computer:    
Description:
Fault bucket , type 0
Event Name: E12IIS
Response: Not available
Cab Id: 0
Ran the below command
Wevtutil.exe cl “Microsoft-Exchange-MailboxDatabaseFailureItems/Operational”
Ran it and restarted the Replication Services
All the copy status came to healthy in sometime
Dump Analyzes
==============
*******************************************************************************
*                                                                             *
*                        Bugcheck Analysis                                    *
*                                                                             *
*******************************************************************************
CRITICAL_PROCESS_DIED (ef)
        A critical system process died
Arguments:
Arg1: fffffa80611bd080, Process object or thread object
Arg2: 0000000000000000, If this is 0, a process died. If this is 1, a thread died.
Arg3: 0000000000000000
Arg4: 0000000000000000
Debugging Details:
——————
PROCESS_OBJECT: fffffa80611bd080
IMAGE_NAME:  wininit.exe
DEBUG_FLR_IMAGE_TIMESTAMP:  0
MODULE_NAME: wininit
FAULTING_MODULE: 0000000000000000
PROCESS_NAME:  MSExchangeHMWo
BUGCHECK_STR:  0xEF_MSExchangeHMWo
DEFAULT_BUCKET_ID:  WIN8_DRIVER_FAULT
   

Changes to the public group memberships cannot be saved; You do not have permission to perform the operation on the object

Issue: Customer is the owner of a distribution group called Testgroup
When trying to add employees from Outlook he gets the following error message:
Changes to the public group memberships cannot be saved; You do not have permission to perform the operation on the object

Cause: This happens, because the distribution group the user wants to modify was created on Exchange server 2007. Type this command from PowerShell to confirm that distribution group has legacy version attribute:
get-distributionGroup testgroup | Fl *Version

This is legacy version:  ExchangeVersion : 0.1 (8.0.535.0)

Solution: The distribution group needs to be updated to later exchange version. Use  Exchange server 2010 or 2013 PowerShell  to update the Exchange version attribute of the distribution group
From Exchange 2013 or Exchange 2010 powershell, type Set-distributiongroup TestGroup. That command updates the exchange version for the DG.

To Verify, type:  get-distributionGroup testgroup | Fl *Version

Version should now display ExchangeVersion: 0.10 (14.0.100.0)

Rebuild Content Index of Exchange 2013 Database

Scenario:  You need to rebuild the Content Index of Exchange 2013 Database.

**Note: There is no ResetSearchIndex.ps1 script in Exchange 2013. Rebuild needs to be performed manually**
Instructions:  
1. Stop the following 2 services”
     – Microsoft Exchange Search Service (Service Name: MSExchangeFastSearch)
     – Microsoft Exchange Search Host Controller (Service Name: HostControllerService)
2. Delete or Move the existing Content Indexing catalog folder (CI Folder) of the Database you wish to rebuilding Content Indexing for.  The CI folder is located in the Database directory and has a folder name of a GUID.  (C:DB01Database27485485-A8dF-4Ed8f-BED8-8C4753D6BA123.11.Single)
3. Start the 2 services you stopped in step 1:
     – Microsoft Exchange Search Service (Service Name: MSExchangeFastSearch)
     – Microsoft Exchange Search Host Controller (Service Name: HostControllerService)

Forward emails that comes to a mailbox to an external address and also keep the mail.

Scenario: you want to forward emails that comes to a particular mailbox to an external address and also keep the mail.

Resolution: Create a mail contact using powershell or Exchange 2013 ECP. If you have exchange 2010 users, you can also use the mgmt console

From Powershell, type Set-Mailbox -Identity ‘testmailbox’ -DeliverToMailboxAndForward:$true -ForwardingAddress ‘mailcontactalias’

The error “Members can’t remove themselves from security groups. Please set the group to Closed for requests to leave.” when editing a distribution group.

Scenario: When editing the managers of a distribution group, this error is displayed:

Members can’t remove themselves from security groups. Please set the group to Closed for requests to leave.

Resolution: Set the MemberDepartRestriction to closed for that distribution group.

set-distributiongroup  <alias of group> -memberdepartrestriction closed

No results display for Exchange Databases in EAC under Servers-Databases, New Mailbox Requests, and New Move Requests

Scenario:  In EAC, you notice that no databases are being displayed under Servers–>Databases. You also notice when adding a mailbox or moving an existing mailbox, no databases are being displayed there either to select.

Solution:  When attempting to open and select a database from the mailbox move request,  the error below was displayed before it returned no results.

Error:  The Exchange server for the database object “Mailbox Database 0348382938490” wasn’t found in Active Directory Domain Services.  The object may be corrupted.

The database referenced was removed from Exchange, but still exists in ADSI Edit. Remove the database in ADSI Edit:

1. Open ADSI Edit in Configuration and navigate to:
-Services
-Microsoft Exchange
-<Exchange Enterprise Name>
-Administrative Groups
-Exchange Administrative Group
-Databases

2. Find that database, and delete it.

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.

Configure bulk Exchange 2013 servers for Unified Messaging and Unified Messaging Call Router Settings.

Configure bulk Exchange 2013 servers for Unified Messaging and Unified Messaging Call Router Settings.

Set the UMService and UMCallRouterSettings for the servers:

Get-UMService |  where {$_.identity -like ‘MBXSVR*’} | Set-UMService -DialPlans dialplan1 -UMStartupMode “dual”

Get-UMCallRouterSettings |  where {$_.identity -like ‘MBXSVR*’} | Set-UMCallRouterSettings -DialPlans dialplan1 -UMStartupMode “dual”


Configure the Exchange Certificate for the UM and UMCallRouter srevices.

Get-ExchangeCertificate -Thumbprint <thumbprint of Certificate> | Enable-ExchangeCertificate -services UM, UMCAllRouter,IIS

Restart the following Services on each server:  MSExchangeUM, MSExchangeUMCR