How to copy a users Office 365 email with PowerShell

 

This is a simple method of “moving” a users email from their Office 365 account to a “Target Folder” in another users account using PowerShell.  If you are unable to access their email in any other way this will work well.

Firstly ensure the user connecting to Exchange Online is a member of the Discovery Management Group.  Certain PowerShell cmdlets are NOT available otherwise.  For example Search-Mailbox

image

  • Connect to Exchange Online with PowerShell

$UserCredential = Credential [email protected]

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

  • Run the below script to search and copy over mail from user A to user B

Search-Mailbox -Identity “user A” -TargetMailbox “user B” -TargetFolder “inbox” -LogLevel Full

image

 

If, on the other hand, you do have access to their Office 365 OWA account then simply login, right click the top level folder and choose permissions.

image

Proceed to add the user who requires permissions and select permission level.  The users mailbox will show up in the target users mail profile at which point they can then choose to export to .pst

image

7 responses to “How to copy a users Office 365 email with PowerShell

  1. I don’t see how this is a move or copy of someone’s email. What I get is a zipped .csv file sent to the target user’s inbox.

    The csv file gives me a list of emails that exist in the original users inbox.

    Unless i am doing something wrong…

    1. Hi Bob what is the PS syntax you are using. What version of Exchange are you connecting to? Are you using the Exchange management shell or connecting to EOL? Do you have the correct permissions IE> a member of the Discovery Management role.

  2. Is there any modification that can be done to simply copy one contact subfolder to another mailbox, and completely overwrite it if it exists?

  3. Hi there Stephanie, very nice post; thanks for sharing!

    I’m looking to attempt a specialized version of this action: to copy (and overwrite if already existing) all the contacts in a specific Contacts subfolder of mine to the same subfolder in all users’ contacts.

    Why would we want to do this? The smartphones at our business will always have the current company address book (and any updated names or phone numbers). Because the Global Address List is search-only, we are missing the nice feature of caller-ID for incoming calls. Caller-ID is not aware of the GAL, unfortunately. Is there any modification that can be done to simply copy one contact subfolder to another mailbox, and completely overwrite it if it exists?

  4. Hi John – Did you ever find a way to import/copy the contact subfolders into individual O365 mailboxes?

    We’re running into the same problem.

    1. We haven’t found any easy scripting solution yet. Hoping for more powershell functionality with Exchange Online in the future.

Comments are closed.