Exchange Online duplicate mailbox

How to resolve duplicate mailboxes in a Hybrid Exchange scenario?

It often happens that companies set up Office365 and then use it alongside the actual Exchange OnPremise infrastructure. For testing purposes or even partially productive. But when it comes to the hybrid scenario and the migration of the local mailboxes, the nasty surprise awaits. The affected user cannot be migrated because a mailbox already exists in the cloud for the same user. It is even more annoying if there is already data in the cloud mailbox. The only workaround here is usually the .pst export.

Read more

New-MailboxImportRequest raising “Error details: Access to the path is denied”

Importing PSTs to an Exchange on-premises mailbox is a cool feature because it helps you to get rid of old legacy PSTs which can cause you a lot of trouble (e.g. corrupted because saved on a network share, accidentially deleted because of hardware switch, etc etc etc).

But sometimes the command to start a new import can drive you crazy as well:

New-MailboxImportRequest

Follow the official documentation for this command to see how powerful it is and how to use it. So when you execute the command you may face the following error:

newmailboximportrequesterror

The error text says:

Unable to open PST file '\\SERVER\c$\Exported PSTs\PSTNAME.pst'. Error details: Access to the path
'\\SERVER\c$\Exported PSTs\PSTNAME.pst' is denied.
 + CategoryInfo : NotSpecified: (:) [New-MailboxImportRequest], RemotePermanentException
 + FullyQualifiedErrorId : [Server=EXCHANGESERVER,RequestId=078dc502-aecb-4122-8e22-f96c1c6141f8,TimeStamp=28.11.2017 10:
 34:01] [FailureCategory=Cmdlet-RemotePermanentException] 7B1A4B04,Microsoft.Exchange.Management.RecipientTasks.New
 MailboxImportRequest
 + PSComputerName : EXCHANGESERVER.FQDN

So the next thing you do is to check the permissions on the folder and they normally look like this:

newmailboximportrequestpermissions

If you read the official documentation very careful, there is a small hint:

You need to grant the following permission to the group Exchange Trusted Subsystem to the network share where you want to export or import PST files:

  • To import PST files from the share: Read permission
  • To save exported PST files to the share: Read/Write permission.

If you don’t grant this permission, you will receive an error message stating that Exchange is unable to establish a connection to the PST file on the network share.

Oh looks like reading the documentation was a good idea, because now the request is being created and the import starts. I personally prefer sharing the folder directly with a $-share. Don’t forget to edit the folder permissions and the sharing permissions. In my case it only worked when I set both:

newmailboximportrequestsuccess

This permission may not be set for a variety of reasons, e.g. a topology with many ActiveDirectory Domains where Exchange is installed in one of the domains, an interrupted permission inheritance or similar.

No matter where it comes from, now you know how to fix it. Happy importing 🙂

Use PowerShell to fill Exchange Mailbox(es) with data

Sometimes you have the need to fill up an Exchange Mailbox up to a certain level, e.g. to test migration speeds. In this post you find a tiny script which can do that for you. All you need is a folder with many files in it and a limit which you want to reach for your mailbox.

[CmdletBinding()]
param( 
 [Parameter(Mandatory=$true)][String]$Recipient, 
 [Parameter(Mandatory=$true)][Int32]$SizeInMB, 
 [Parameter(Mandatory=$true)][String]$FilesFolder, 
 [Parameter(Mandatory=$true)][String]$O365Sender
)
$ErrorActionPreference = 'SilentlyContinue'

[Double]$totalsize = 0
[Double]$attsize = 0
$pw = Read-Host ("Please enter the password for " + $O365Sender) -AsSecureString | ConvertFrom-Securestring
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $O365Sender, ($pw | ConvertTo-SecureString)
#$files = Get-ChildItem -Path $FilesFolder -Exclude "*.mp4" -Recurse
$files = Get-ChildItem -Path $FilesFolder -include "*.pptx" -Recurse
$mailcount = 1
while ($totalsize -lt $SizeInMB)
{ 
 $attachment = $files[(Get-Random -Minimum 0 -Maximum ($files.Count - 1))].FullName 
 $attsize = ((Get-Item $attachment).Length / 1000000) 
 $totalsize += $attsize 
 Write-Host ("Sending mail number " + $mailcount.ToString() + "; total size: " + $totalsize.ToString()) 
 Send-MailMessage -From $O365Sender -to $Recipient -Attachments $attachment -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Subject ("Mail number " + $mailcount.ToString() + " via PowerShell script") -port 587 -body "<br><h1>Hallo</h1><br><br>Dies ist eine automatische Mail<br><br>Regards,<br>Your PowerShell Bot" -BodyAsHtml  
 $mailcount++
}

As you see, the script is designed to send mails from an Office 365 Exchange Online Mailbox. It is using the SMTP client submission of Exchange Online. So you are limited to 30 messages per minute (by Nov 17th 2017, this limit may change any time).

The parameters of the script:

  • $recipient: The smtp address of the mailbox which should be filled.
  • $SizeInMB: The amount of data which will be sent. The script counts how many MBs are sent and will stop when it reaches the limit. It doesn’t check the actual mailox size so the result maybe lower because of single instance store technologies or similar.
  • $FilesFolder: The folder with data for the email attachments. The script will pick a random pptx-file from this folder and send it via email. If you’d like other file types than pptx, just change the search filter. I’ve decided for pptx files because they are often large and I have tons of them. If you need tons of files, try the Ignite downloader.
  • $O365Sender: The sign in name of the mailbox from where you want to send the emails.

With some small adjustements you can use the script also with an on-premises mailbox as a sender. Happy mailbox filling 🙂

Feel free to download the script from my GitHub Page: PowerShell-ExchangeOnline GitHub Repository