Tag Archives: exchange 2007

How to: Remove duplicate items from Exchange Mailboxes using Powershell

During an Exchange migration you sometimes have the issues where users complain that there are duplicate entries of their calendar items. This is normal to happen and can be done directly from the server using Powershell . You will need to download the script here and then install Managed API 1.2 or later which can be downloaded here.

Remove-DuplicateItems.ps1 [-Mailbox] <String> [[-Type] <String>] [-Server <String>] [-Impersonation] [-DeleteMode <String>] [-Mode <String>][-WhatIf] [-Confirm] [<CommonParameters>]

The syntax is below:

-Mailbox is the name of the mailbox to process;
-Type determines what folders are checked for duplicates. Valid options are Mail, Calendar, Contacts, Tasks, Notes or All (Default);
-Server is the name of the Client Access Server to access for Exchange Web Services. When omitted, the script will attempt to use Autodiscover;
-When the Impersonation switch is specified, impersonation will be used for mailbox access, otherwise the current user context will be used;
-DeleteMode specifies how to remove messages. Possible values are HardDelete (permanently deleted), SoftDelete (use dumpster, default) or MoveToDeletedItems (move to Deleted Items folder).
-Mode determines how items are matched. Options are Quick, which uses PidTagSearchKey and is the default mode, or Full which uses a predefined set of attributes to match items, depending on the item class.

For this to work you need to setup the impersonation of the user which you will be running the script. This can be done as below for Exchange 2010

New-ManagementRoleAssignment -Name ImpersonationRole -Role ApplicationImpersonation -User administrator

-Name : Can be anything you put in, it’s just a name
-User: Is the user you will be impersonating as

On Exchange 2007 you can use the below command:

Get-ExchangeServer | where {$_.IsClientAccessServer -eq $TRUE} | ForEach-Object {Add-ADPermission -Identity $_.distinguishedname -User (Get-User -Identity User1 | select-object).identity -extendedRight ms-Exch-EPI-Impersonation}

More info on the script here

(9972)

How to: Manually purge Exchange server logs safely

Many had this problem when in crisis, one would need to purge the Exchange logs but ended up not doing it for the fact that it would be risky and not safe. One can manually and safely purge the Exchange logs with the below script. Open a command prompt and type the following.

Note: the m: would be your drive where the Exchange Mailbox databases are.

diskshadow
add volume m:
begin backup
create backup

At this moment, nothing will happen and after some time the screen will be populated. As soon as you see the prompt, enter the below.

end backup

After some time, you will see the space decreasing and the logs being purged. Although this works on Exchange 2010, it would be the same for Exchange 2007.

(2305)

How to: Connect Remotely to an Exchange Management Shell

Powershell is a great tool and sometimes you need to connect to your prefered Exchange server without opening a remote desktop on the server. To connect remotely to any Exchange Management Shell you need the following:

To connect to the server using the logged-in user type,

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://my-exchange-server/PowerShell/ -Authentication Kerberos

and then type

Import-PSSession $Session

If you want to connect to the server using specified credentials, type the following,

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://my-exchange-server/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session

That should connect you to the desired server… enjoy

(1166)

How to: Allow application to relay through Exchange server

When having applications to explicity relay mail inside or outside your network with Exchange server you might have some problems. This can be solved by creating a Receive connector in your Exchange infrastructure. This can be done as below:

Open Exchange Management Console
Navigate to Server Configuration and Hub Transport
Select the server
Right click on the Receive connector area
Select New Receive Connector
Enter the name for the connector
Select Custom
On the Local Network settings click Next
On the Remote Network setting enter the IP address or range from where the emails will be sent
Once created open the properties of the connector
Open the Permissions Group tab
Tick Anonymous Users and Exchange Servers
Open the Authentication tab
Tick Transport Layer Security (TLS)
Tick Externally Secured (for example, with IPSEC)

Try to send the email and there you have it.

(116571)

Fix: No mailflow due to 430 4.2.0 STOREDRV; mailbox logon failure error

You will notice that there is a problem with mailflow and on the Queue Viewer in your Exchange setup you will notice that the mailflow is stuck for a good number of messages. You will also notice that the error message is 430 4.2.0 STOREDRV; mailbox logon failure.

You can also see the event viewer showing the Event ID 1009 in the Application log: The Microsoft Exchange Mail Submission service is currently unable to contact any Hub Transport servers in the local Active Directory site. The servers may be too busy to accept new connections at this time.

This can be because that the Microsoft Exchange Transport Service and Microsoft Exchange Transport Log services are running with a user and not the Network Service or Local System.

To fix this, open the Services.msc and set both services to Log On As Network Service or Local System. Restart both services and mailflow should get moving.

(3544)