Tuesday, June 26, 2012

Create new self signed cet for exchange 2010

From exchange powershell: New-ExchangeCertificate -FriendlyName "SelfSigned Cert" -SubjectName "cn=mail OR remote.domain.com" -DomainName SERVERNAME,SERVERNAME.domain.local,mail OR remote.domain.com,autodiscover.domain.com-PrivateKeyExportable $True Chose to overwrite the existing cert. Next enable the cert: enable-exchangecertificate -donotrequiressl service type: pop, imap, iis, smtp enter the thumbprint for the new certificate. From exchange consoole you can export the cert to be installed on machines.

Tuesday, June 12, 2012

Recover deleted exchange messages/folders

So you have a user who deleted a message or a folder from Exchange 2010 and you can't find it in the dumpster, here is how to setup a recovery database and restore the file. First restore the database file and logs to a recovery folder. I will be restoring the files to an external drive since we do image based backups hourly, I don't need another backup of my backup file. My external drive is E and my exchange data is located at: C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database 2011072209 Make sure you restore the DB and all the log files, basically restore the entire folder! From here check to see if the database is in a dirty shutdown state so from the powershell run: eseutil /mh “E:\Recovery\mailbox database 2011072209.edb” Notice the name of the mailbox DB, yours may be different. After running the command look for a line that says "State: Dirty Shutdown" If it reports this we need to check the status of the logs, again from powershell: eseutil /ml E:\Recovery\E00 (E00 is the prefix to the log files located in the database folder) The command should respond with "No Damaged log files were found) If so, we can attempt to brind the database into a clean shutdown: (powershell) eseutil /r E00 /i /l E:\Recovery\ /d 'E:\Recovery\Mailbox Database 2011072209.edb' The first section, E:\recovery is location of the log files, the second location is the database name. The operation will complete reletively quick, however it doesn't mean it fixed the database, so we run a command to check the status: eseutil /mh 'E:\Recovery\mailbox database 2011072209.edb' | findstr "State:" If you get good news and it reports "State: Clean Shutdown" great, if not, we repair! eseutil /p 'E:\Recovery\mailbox database 2011072209.edb' This baby will take a long time, when you thing its hung, its not! After the process completes, rerun the findstr command again: eseutil /mh 'E:\Recovery\mailbox database 2011072209.edb' | findstr "State:" If it reports clean, mount the recovery database!! First, create a log folder in the subfolder of your recovery folder. Next we run a command to create the database: New-MailboxDatabase RecoveryDB -Server Servername -Recovery:$true -EdbFilePath 'E:\Recovery\mailbox database 2011072209.edb' -LogFolderPath 'E:\Recovery\rec' The first section we enter the exchange server name, next the database file name, lastly the location for the logfiles to go. This needs to be an empty folder and created ahead of time. Next, mount the DB: Mount-Database RecoveryDB Next we can list the contents of the database to ensure our users data is there: Get-MailboxStatistics -Database RecoveryDB Once the database is mounted, recover the mailbox. For this example the mailbox will be recovered to the original users mailbox. It will appear as a subfolder in the root of his mailbox: Restore-Mailbox -Identity "User Name" -RecoveryDatabase RecoveryDB -RecoveryMailbox "User Name" -TargetFolder Restore Now, this is going to restore the users mailbox to the original user, we can however restore it to someone elses mailbox. Also for the user name quotations are not needed if there is no space in the user name. We are restoring the mail to a folder named "Restore" however this folder can be named anything you want.