Recover Exchange


Have you ever had have a situation where you need to just start over with your exchange server but don’t want to lose data? (OS corruption\ Hardware Failure\ too many undocumented changes that caused an outage)

Here are the “quick and easy steps to recover”

  1. Stop the “Microsoft Exchange Information Store” service
  2. Note the OS service pack level\patches\hotfixes
  3. Copy or backup all your database files *.edb (if they are on a drive other than C you may not even have to do that)
  4. Format the C: (that’s right format it, so if you have something else on it back it up)
  5. Reinstall the OS and re-service pack it
  6. Rejoin the domain using the same server name as before (this is critical)
  7. install the exchange prerequisites.
    1. 2003
    2. 2007
    3. 2010
  8. Reinstall using exchange media
    1. 2003 = setup /disasterrecovery
    2. 2007\2010 = setup /m:recoverserver
  9. Copy or restore the exchange databases back to the original location
  10. mount the databases
  11. DONE! exchange should be back up and running!
Advertisements

Manual uninstall of Exchange 2k7 Edge server


When trying to uninstall Edge role you receive this message
“cannot find information about the local server in active directory. this may be related to a change in the server name”.

Even after setting name back to the original still cannot uninstall
If possible the best solution is to use remove-edgesubscription from the hub server, and format and re-install the edge server role.

Or if this is not possible

Perform a manual uninstall of Exchange Edge role

WARNING: Always be sure to have a backup of a Domain controller system state and registry of the server before making any changes

  1. 1. Install and use “Windows Installer Cleanup Utility” to uninstall Exchange all 2007 entries on the edge server
    1. Use ADSIEdit.msc (may need to install from support tools) to remove the following entries
      1. Open ADSIedit.msc on the domain controlle
        1. Right click ADSI Edit and click connect to
        2. Select Configuration under well known naming contex
        3. Select Default (domain or computer that you logged in to
        4. Click o
      2. Browse to CN=Configuration, CN=Services, CN=Microsoft Exchange, CN=First Organization, CN=Administrative Groups, CN=Exchange Administrative Groups (FYDIBOHF23SPDLT), CN=Servers
        1. Delete CN=<edgeserver
    2. Open ADSIedit.msc on the Edge serve
      1. Right click ADSI Edit and click connect to
        1. Click Advanced and change port to: 50389
        2. Select Configuration under well known naming contex
        3. Select Default (domain or computer that you logged in to
        4. Click ok
      2. Browse to CN=Configuration, CN=Services
        1. Delete CN=”Microsoft Exchange” key
  2. Delete DNS entry for edge (not sure that was needed either)
  3. On the edge Server run Regedit
    1. Delete all the MSExchange keys under HKLM\System\currentcontrolset
    2. Delete HKLM\software\microsoft\Exchange
    3. Delete HKLM\SYSTEM\Currentcontrolset\services\ADAM_MSExchange
    4. Delete HKLM\SYSTEM\Currentcontrolset\services\ EdgeCredentialsvc
    5. Delete HKLM\software\microsoft\software\windows\currentVersion\uninstall\ADAM_MSExchange$0
    6. Delete HKLM\software\microsoft\software\windows\currentVersion\uninstall\Microsoft Exchang
  4. Delete c:\program files\Microsoft
  5. Renamed c:\ExchangeSetupLogs to c:\old_ExchangeSetupLogs
  6. reinstall Edge

How to Fully Re-Install Exchange On SBS 2008


(Note: this will remove from your environment so you will have to re-create\attach mailboxes)

Recently I had a situation where I needed to fully remove and re-install Exchange on SBS2008, here is the process I was able to develop using technet, a couple blogs and trial an error

Prep For uninstall

Run Exchange Management Shell as administrator

Answer A or Y to all PS Prompts

  1. Remove all mailboxes
    • Get-mailbox | disable-mailbox
  2. Remove-receive Connectors
    • Get-recieveconnector | remove-recieveconnector
    • Get-sendconnector | remove-sendconnector
  3. Remove Public Folder and oab
    • Get-offlineaddressbook | remove-offlineaddressbook
    • Adsiedit.msc – > Connect to : Configuration ->
    • Configuration -> Configuration -> Services -> Microsoft Exchange -> First Org.. -> administrative Groups -> Exchange Admin Group.. -> Servers -> Servername -> Information Store -> Second Information Store -> Right Click and delete “Public Folder Databas
      image

Uninstall

  1. Start -> control -> programs and features -> Microsoft Exchange -> uninstall -> uncheck all roles ->
    image
  2. Rename Databases Folders
    1. From Powershell > move c:\program files\Microsoft\Exchange Server\mailbox” c:\program files\Microsoft\Exchange Server\mailbox.old”

Re-Install Exchange

  1. Download Exchange2007 SP1 (E2K7SP1EN64.exe)  http://www.microsoft.com/downloads/details.aspx?FamilyID=44c66ad6-f185-4a1d-a9ab-473c1188954c&displaylang=en
  2. Create a registry value to use with Windows SBS 2008 Disc 2 (Component Technologies for Server Repair) and Microsoft Exchange Server 2007 by doing the following:
    1. Open Registry Editor.image
    2. On the User Account Control page, click Continue.
    3. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\461C2B4266EDEF444B864AD6D9E5B613\SourceList\Media.
    4. Create a new string value named MediaPackage: Right-click Media, click New, click String Value, in Name type MediaPackage, and then press ENTER.
    5. Double-click MediaPackage, in Edit String, in Value data, type \CMPNENTS\Exchange12\, and then click OK.
    6. Close Registry Editor.
  3. Run the Setup from the extracted Directory, Rt click Setup and Run As Administrator
  4. Click Step 4: Install Microsoft Exchange Server 2007 Sp1
  5. Next -> Select Mailbox\CAS\HUB
    image 
  6. Enter Org Name (Default is “First Organization”)
    image 
  7. Next
    image

SBS Roles Reinstall Script

  1. Run Windows PowerShell commands by doing the following:
    1. Copy and paste the following cmdlets into a text file: (Run Notepad as administrator)
        $LocalServerName = hostname$ActiveSyncMailboxName = “Windows SBS Mobile Mailbox Policy” + ” ” + $LocalServerName

        $OABVDir = $LocalServerName + “\OAB (SBS Web Applications)”

        $OAB = Get-OfflineAddressBook | Select-Object -Property Name

        $strDomainDNS = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name

        $DomainAdmins = $strDomainDNS + “\Domain Admins”

        $OrgName = Get-OrganizationConfig | Select-Object -Property DistinguishedName

        $DefaultExchangeCertificate = “CN=” + $LocalServerName

        Get-ExchangeCertificate | Where { $_.Subject -eq “$DefaultExchangeCertificate” } | ForEach { Remove-ExchangeCertificate -Thumbprint $_.Thumbprint }

        Set-ForeignConnector “Windows SBS Company Web Connector $LocalServerName” -SourceTransportServers $LocalServerName

        REG ADD HKLM\SYSTEM\CurrentControlSet\Services\MSExchangeIS\ParametersSystem /v “Disable MAPI Clients” /t REG_SZ /d 0.0.0-5.3164.0

        Get-MailboxDatabase | Set-MailboxDatabase -OfflineAddressBook $OAB.Name -DeletedItemRetention “30.00:00:00”

        Get-StorageGroup | Set-StorageGroup -CircularLoggingEnabled 1

        Remove-OWAVirtualDirectory -Identity “Owa (Default Web Site)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Exadmin (Default Web Site)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Exchange (Default Web Site)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Exchweb (Default Web Site)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Public (Default Web Site)” -Confirm:$false

        Remove-WebServicesVirtualDirectory -Identity “EWS (Default Web Site)” -Confirm:$false

        Remove-ActiveSyncVirtualDirectory -Identity “Microsoft-Server-ActiveSync (Default Web Site)” -Confirm:$false

        Remove-OabVirtualDirectory -Identity “OAB (Default Web Site)” -Force:$true -Confirm:$false

        Remove-UMVirtualDirectory -Identity “UnifiedMessaging (Default Web Site)” -Confirm:$false

        Remove-AutodiscoverVirtualDirectory -Identity “Autodiscover (Default Web Site)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Exadmin (SBS Web Applications)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Exchange (SBS Web Applications)” -Confirm:$false

        Remove-OWAVirtualDirectory -Identity “Public (SBS Web Applications)” -Confirm:$false

        New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2007” -ExternalAuthenticationMethods Fba

        Set-OWAVirtualDirectory -InternalUrl “https://sites/owa/&#8221; -ClientAuthCleanupLevel “Low” -LogonFormat “UserName” -DefaultDomain $strDomainDNS -Identity “Owa (SBS Web Applications)”

        New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000” -VirtualDirectoryType “Exadmin” -ExternalAuthenticationMethods Fba

        New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000” -VirtualDirectoryType “Mailboxes” -ExternalAuthenticationMethods Fba

        New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000” -VirtualDirectoryType “Exchweb” -ExternalAuthenticationMethods Fba

        New-OWAVirtualDirectory -WebsiteName “SBS Web Applications” -OwaVersion “Exchange2003or2000” -VirtualDirectoryType “PublicFolders” -ExternalAuthenticationMethods Fba

        New-WebServicesVirtualDirectory -WebsiteName “SBS Web Applications” -InternalUrl “https://Sites/EWS/Exchange.asmx&#8221; -basicauthentication 1 -windowsauthentication 1

        New-ActiveSyncVirtualDirectory -WebsiteName “SBS Web Applications” -InternalUrl “https://Sites/Microsoft-Server-ActiveSync&#8221; -ExternalAuthenticationMethods Basic -InternalAuthenticationMethods Basic

        New-OabVirtualDirectory -WebsiteName “SBS Web Applications” -InternalUrl “https://Sites/OAB&#8221;

        Set-OabVirtualDirectory -PollInterval “30” -Identity “oab (sbs web applications)”

        New-UMVirtualDirectory -WebsiteName “SBS Web Applications” -InternalUrl “https://Sites/UnifiedMessaging/Service.asmx&#8221;

        New-AutodiscoverVirtualDirectory -WebsiteName “SBS Web Applications” -InternalUrl “https://Sites/Autodiscover/Autodiscover.xml&#8221; -BasicAuthentication 1 -WindowsAuthentication 1

        Set-ClientAccessServer -Identity $LocalServerName -AutoDiscoverServiceInternalUri “https://sites/Autodiscover/Autodiscover.xml&#8221;

        Set-OfflineAddressBook $OAB.Name -VirtualDirectories $OABVDir -Versions Version2,Version3,Version4 -PublicFolderDistributionEnabled:$True

        iisreset /noforce

        cd $env:windir\system32\inetsrv

        .\appcmd.exe unlock config “-section:system.webserver/security/authentication/windowsauthentication”

        .\appcmd.exe set config “SBS Web Applications/ews” “-section:windowsAuthentication” “-useKernelMode:False” /commit:apphost

        .\appcmd.exe set config “SBS Web Applications/AutoDiscover” “-section:windowsAuthentication” “-useKernelMode:False” /commit:apphost

        .\appcmd.exe set config “SBS Web Applications/oab” “-section:windowsAuthentication” “-useKernelMode:False” /commit:apphost

        .\appcmd.exe set site “Default Web Site” /Bindings:http/*:80:

        .\appcmd.exe start site “Default Web Site”

        .\appcmd.exe start site “SBS Web Applications”

    2. Name the text file sbsAllrolereinstall.ps1, and then save it in C:\windows\system32.
    3. Open Exchange Powershell: Click Start, click All Programs, click Microsoft Exchange Server 2007, right-click Exchange Management Shell, and then click Run as administrator.
    4. On the User Account Control page, click Continue.
    5. In Exchange Management Shell, type .\sbsAllrolereinstall.ps1, and then press ENTER.
    6. Type Y to confirm the action, and then press ENTER.
    7. Close Exchange Management Shell.
  2. Update the settings in the Internet Information Services (IIS) Manager by doing the following:
    1. Click Start, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
    2. On the User Account Control page, click Continue.
    3. Expand the name of your Windows SBS 2008 server, and then expand Sites.
    4. Click Default Web Site, and then click Start.
    5. Expand SBS Web Applications, and then click OAB.
    6. In OAB Home, double-click SSL Settings.
    7. Select Require SSL and Require 128-bit SSL, and then click Apply.
  3. To send e-mail messages to the Internet, run the Fix My Network Wizard by doing the following:
    1. Open the Windows SBS Console.
    2. On the navigation bar, click Network, and then click Connectivity.
    3. In the task pane, click Fix my network.
    4. Follow the instructions in the wizard. You can click each potential problem that the wizard lists to get more information about the problem. To recreate the default Send and Receive connectors to re-establish mail flow, select Exchange SMTP connectors are invalid.
  4. Rerun the Internet Address Management Wizard to associate the new virtual directories with the correct external URL.
  5. If your server uses a trusted certificate, you must also run the Add Trusted Certificate Wizard.
  6. You may end up with the exchange saying its not license you can register Exchange on SBS with this tool.
      Activate Exchange
      http://rahman.eu/ActivateExchange.exe

Info gathered from

Rahman® Reviews

http://duitwithsbs.wordpress.com/2009/04/28/sbs-2008-how-to-repair-exchange-2007/
http://technet.microsoft.com/en-us/library/dd728006(WS.10).aspx
List of SBS Recovery options.
http://technet.microsoft.com/en-us/library/dd430085%28WS.10%29.aspx

  1.  

Problem after deleting legacy exchange administrative group


To start with you generally do not want to delete it but if you already did…..Start ADSI Edit. In the CN=Configuration container, locate the following container:

CN=Services,CN=Microsoft Exchange,CN=ORGANIZATION,CN=Administrative Groups,CN=administrative_group,

Now we were missing the ‘Folder Hierarchies’ folder – All we have to do is recreate it as follows:
Create the “Folder Hierarchies” under the Exchange Administrative Group

1. Right click on Exchange Administrative Group
2. Select New Object
3. Select msExchPublicFolderTreeContainer for the class and click Next
4. Enter the following for the value: Folder Hierarchies, click Next
5. Click Finish

Create Public Folder Tree Object

1. Right click CN=Folder Hierarchies -> New Object
2. Selected msExchPFTree for the class
3. For the value we entered, “Public Folders” and clicked next
4. Clicked on the “More Attributes” button, selected msExchPFTreeType and set the
value to 1. Note: This is very important that this value is set to a value of 1 as
this tells Exchange that this is a MAPI Tree
5. Click Ok and then finish

Populate msExchOwningPFTreeBL attribute object of the PF Stores in the organization
(Since this attribute is not directly editable, you have to follow the below steps
to do this for each PF store)

1. Get properties of the newly created “Public Folders” Tree object in ADSIEdit.
2. Copy the distinguishedname value to the clipboard and then click cancel.
3. Navigate to the Storage group that contains the Public Folder Store for this
server and get properties of the server database.
4. Locate the msExchOwningPFTree attribute and paste in the value that was copied
to the clipboard in step 2. Click OK.
5. Restart the Information Store Service

Set permissions on the Public Folders

  1. Start ADSI Edit. In the CN=Configuration container, locate the following container:
    • CN=Services,CN=Microsoft Exchange,CN=ORGANIZATION,CN=Administrative Groups,CN=administrative_group,CN=Folder Hierarchies,CN=Public Folders
    • Note In this container, ORGANIZATION is the name of the Exchange Server organization and administrative_group is the name of your administrative group.
  2. Right-click CN=Public Folders, and then click Properties.
  3. Click the Security tab.
  4. Make sure that the Allow inheritable permissions from parent to propagate to this object check box is selected.
  5. Make sure that the Everyone group has the following Allow permissions:
    • Create named properties in the information store
    • Create public folder
    • Create top level public folder
    • If the Allow inheritable permissions from parent to propagate to this object check box is selected, the Everyone group should already have these permissions. Make sure that the Deny check boxes are not selected.
  6. Now try to mount the PF store and see if we can access it fine now.

How To: Exchange database Recoveryor Become an Exchange database Recovery expert!!!!!


SUMMARY

This article describes how to use the Microsoft Exchange Server Eseutil tool (Eseutil.exe)  

How to Recover a Corrupt Exchange Database

  1. Be sure there are no hardware issues and that the File System is intact (run chkdsk /r and repeat until it doesn’t return errors), restore from backup is preferable if possible.
  2. Add the Exchange bin to the “path” statement
    1. Start -> Right click my computer -> properties -> advanced Tab -> environment variables (scroll down if you have to)
    2. In the bottom pane double click “path”
    3. Go to the end of the line enter a semi-colon and enter the path to the exchange bin directory
  3. Verify that there is twice as much free space as the size of the database,
    i.e if the database is 10 gb you need to have at least 20 gb free
  4. Open command prompt
  5. Change to the directory where the database is (usually C:\program files\exchsrv\mdbdata, if you cant find the database search for *.edb)
  6. Type eseutil /mh <database name> (usually priv1.edb)
    1. Look for the shutdown state (may have to scroll up) , if its in clean shutdown then you should be able to mount the database, but chances are if your reading this its in a dirty shutdown and you need to continue on
  7. Type eseutil /k <database name> (usually priv1.edb) look for “Bad Checksums” if you have any, your repair possibility will be slim (just make a note of it)
  8. Type eseutil /ml e00 we are looking for any missing logs (if none missing go on to step 9)
    1. if there are any we have to move all subsequent logs. and the e00 log to another location, rename the last log to e00.log
    2. Example we have logs E00021-E00035 and E00033 is missing, remove E00, E00034 and E00035
  9. Re-name the .chk file to .oldchk
  10. Type eseutil /r E00
    1. Wait for that to complete, if it completes successfully move on to 11 otherwise run “P”
      1. P. eseutil /p <database name> this will force the database into a clean shutdown and will rip out any incomplete pages, this should only be done as a last resort
  11. Start information store service, verify that the store is mounted in Exchange System Manager (ESM), if its not mounted right click and mount
    1. Start -> All Programs -> Microsoft Exchange -> System Manager
    2. Expand Administrative Group -> Administrative group -> Servers -> {Server name} -> {Storage Group}
    3. Right Click Mailbox store -> mount
  12. Dismount the store in ESM
  13. Go back to the command window
    1. type isinteg –s <servername> -fix –test alltests
    2. When prompted select the store that you repaired
    3. If any fixes are reported re-run until none are reported (just like chkdsk)
  14. Type eseutil /d <database name> (usually priv1.edb)
  15. Remount the database and should now be able to send receive mail

Command Description
Eseutil is a Jet database repair utility
Switch Action
/D Defragments the database
/R Soft recovery of the database
/G Integrity Check
/K Checksum
/P Hard Repair
/ML Log File dump
/MH Database file dump
/Y Copy
/C Restore

Isinteg is a integrity checker much like the windows chkdsk for NTFS

ESM Exchange System Manager is the GUI Management tool for exchange
Exchange 2007 changed the name to EMC Exchange Management Console

REFERENCES

For more information about Exchange 2003, visit the following Microsoft Web site:
http://technet.microsoft.com/en-us/library/bb123872.aspx

Use the Eseutil Utility to Detect File Header Damage in Exchange 2003
http://support.microsoft.com/kb/825088

How to defragment with the Eseutil utility (Eseutil.exe)
http://support.microsoft.com/kb/192185

Description of the Isinteg utility
http://support.microsoft.com/kb/182081