Monday, January 11, 2010

Soft recovery of Exchange 2003 database

A step by step walk-through of procedure to be followed when exchange database fail to mount in Exchange System Manager. Please note that I have personally tried these steps with MS premier support executive on call, however I take no guarantee that

1. Ensure that Exchange System Attendant and Exchange Information Store service are started.
2. Now try to mount the database and if database is not mounting and giving an error then check the shutdown state of the database.
3. To check whether database are in clean shutdown or dirty shutdown. Run the below command from the “Exchsrv\bin” directory:

Eseutil /mh “Path of the database” as indicated below and check the state of the database for e.g. :

Eseutil /mh “K:\EXCHANGE20-SG01-DB\EXCHANGE20-SG01-MBX01.edb”




4. Check if the database is in dirty shutdown state. If yes then also check for the “Log required” field as shown above and make sure you have those log files for soft recovery.

5. To check how many logs files have been committed to the database RUN Eseutil /mk “path of the checkpoint file”

Eseutil /mk “L:\EXCHANGE20-SG01-LOGS\E00.chk”

The result of the above command and the logs required as per /mh may not match of the chk file is corrupt. The more reliable output is from /mh

6. To make sure that all the log files are consistent, run
Eseutil /ml “Path of the log files\log prefix” as indicated below.
Eseutil /ml “L:\EXCHANGE20-SG01-LOGS\E00”

Below command will help you check the health of all the log files in the location. Be careful that this command will take VERY long time to complete if you have too many files in the log folder.

A better option is to move the committed log files to a backup folder and then run the above command on the remaining log files to check the consistency of uncommitted log files.





7. You may not see the last log file required in the log folder because that log file may be E00.log. You can find the actual log file name of e00.log “Eseutil /ml “Path of Log File\e00.log”

8. Make sure that you have all the logs files in sequence and are in consistent state which have not yet been committed and if any log file is missing or corrupted then soft recovery will not be successful.

9. To run the soft recovery run the command “Eseutil /r Enn /L “Path of the log files” /d “path of database file”.

E.g. Eseutil /r E00 /l “L:\EXCHANGE20-SG01-LOGS” /d “K:\EXCHANGE20-SG01-DB\EXCHANGE20-SG01-MBX01.edb”






If the above command fails, you can include the switch “/s” for giving the location of the “.chk” file.

Another switch /i can be appended to the above command to ignore the other databases that run off the same set of log files if they are mounted.

7. If the above command does not work then you can cut and paste all the committed log files and Enn.chk from the log drive in another location as backup and try mounting the database. Exchange will create a new chk file and will try to do a soft recovery itself.

If all the above steps do not succeed it is time to call Microsoft and log a SEV 1 case with them.

------------ End of Document ------------------------
Tags: Exchange Server
Published Date: 20100111

Thursday, January 7, 2010

How to delete an email from a mailbox using Exchange Shell

There have been times when a user has sent an email to a big DL and wants it to be recalled. We all know that Exchange recall feature is not much effective. However in Exchange 2007 you can scan all mailboxes and delete the email from them. The best way is to narrow your search as much as possible.

However remember that you need an account which has full access to the mailbox from which you want to delete the email. The BES service account generally has that permissions. You will have to "Run As" the EMS with this account.

Below are two examples of such command.

Get-Mailbox -Server SERVER_NAME -resultsize unlimited | Where-Object {$_.OrganizationalUnit -like "Mydomain.corp/OU/OU/OU*"} | Export-Mailbox -SubjectKeywords "Some keywords from the subject line" -DeleteContent -StartDate 10/08/2009 -IncludeFolders "\Inbox"

The above command finds all mailboxes from a particular server and which are in a particular OU. It then users the Export-Mailbox command to delete the mails as per the specified criteria.

StartDate is use to delete the emails that are after the specified date. You can also use EndDate to specify the range.

Include Folders further narrows the search and reduces the scan time considerably.

Get-Mailbox -Server SERVER_NAME -resultsize unlimited | Export-Mailbox -SenderKeywords "Sender's SMTP address" -DeleteContent -StartDate 10/08/2009 -IncludeFolders "\Inbox"

You can also delete emails from a specific sender using the above command.

Please be careful to test this command before running in production environment as you may end up deleting emails from users mailbox that they need if any wrong criteria is chosen.

------------ End of Document ------------------------
Tags: PowerShell, Exchange Server
Published Date: 20100107

Thursday, December 31, 2009

Remove all DL membership from a user

As part of account termination process, it is often required that the user should be removed from all DLs. This is generally a manual process because of the way AD stores Group Membership information. However you can use Quest Management Shell and achieve the task in one line.

Import-Csv c:\My_UserNames.csv | foreach {(Get-QADUser $_.DisplayName).memberof | Get-QADGroup | Remove-QADGroupMember -Member $_.DisplayName}

The above line will read all names from a CSV. It will then find the DLs that the user is a member-of and call Remove-QADGroupMember to remove the member from the specified DLs. This command will run on all the DLs that a user is a member-of. 'foreach' will cause the entire command to run for all the users listed in the csv file.

We need to pipe it to Get-QADGroup because .memberOf spits the DN of the DLs and Remove-QADGroupMember will not take the DN as the identity for the DL.

------------ End of Document ------------------------
Tags: Active Directory, PowerShell, Exchange Server
Published Date: 20091231

Wednesday, November 18, 2009

Change multiple user password using command line

Quest QAD shell provides a very useful interface to do this often required task. The beautiful part is that you do not need to provide the password as a Secure string.

Set-QADUser –Identity –UserPassword -UserMustChangePassword $True

The above command will set the password for User to the one specified in this command.

Import-Csv UserList.csv | foreach {Set-QADUser -Identity $_.UserName -Password $_.UserPassword -UserMustChangePassword $True}

The above command will read the UserName and UserPassword from and excel sheet UserList.csv and will set them accordingly. You need to keep the row headers as UserName and UserPassword in the CSV. The most important feature here is that you can have a different password for each individual user in the sheet.

------------ End of Document ------------------------
Tags: Active Directory, PowerShell,
Published Date: 20091118

Friday, March 6, 2009

Convert lastlogon or laslogontimestamp to date

It is always difficult to convert the large integer value on the account's property. The date is stored as a large integer. To convert it you can use the built in w32tm command:


w32tm /ntte 128787219065874052
[Output] 149059 06:45:06.5874052 - 2/10/2009 12:45:06 AM (local time)

w32tm /ntte 128805109570324972
[Output] 149079 23:42:37.0324972 - 3/2/2009 5:42:37 PM (local time)

------------ End of Document ------------------------
Tags: Active Directory, Windows Server 2003, Windows Server 2008
Published Date: 20090305