Exchange 2013 Export/Delete

I'm looking for two powershell commands for a client of mine. Here are their requirements.

1. Mass export of all mailboxes from Exchange 2013 to PST with aggressive error detection
2. Mass delete all contents from mailboxes within date range without touching contacts and calendars
TheNetworkPro15Asked:
Who is Participating?
 
Will SzymkowskiSenior Solution ArchitectCommented:
I have modified the original delete script.

$startdate = (read-host "type start date format: mm/dd/yyyy)
$enddate = (read-host "type end date format: mm/dd/yyyy)
Get-Mailbox -ResultSize "unlimited" |
Search-Mailbox -StartDate $startdate -EndDate $enddate -DeleteContent

Open in new window


When you run this script it will prompt you to enter the start and end dates first and then the script will run using those date values.

Just run the script as is. Do not change the start and end dates in the script as it will prompt you for those values when you run it. The values in the script for read host just give you an example, so just leave them.

Will.
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
You need to assign the Import/Export role assignment to a group or a user.

Assign Import Export Role to a Group.
New-ManagementRoleAssignment -Name "Import Export_Enterprise Support" -SecurityGroup "Enterprise Support" -Role "Mailbox Import Export"

Open in new window


Mass Export of All Mailboxes from Exchange 2013
$Mailboxes = Get-Mailbox -ResultSize "unlimited"
ForEach ($Mailbox in $Mailboxes) {
New-MailboxExportRequest -Mailbox $Mailbox -FilePath \\server\sharename\$mailbox.pst
}

Open in new window


Search Mailboxes and Delete Content older than 1 year.
$Date = Get-Date
Get-Mailbox -ResultSize "unlimited" | Search-Mailbox -StartDate $date -EndDate $date.adddays(-365) -DeleteContent

Open in new window


The script above will get all mailboxes and then search the mailboxes for all messages that are between Todays Date ($date) and Todays Date -365 (1 year old) and delete the content. You can adjust these settings based on your requirements.

Will.
0
 
TheNetworkPro15Author Commented:
Thank you for this. I have one more request..Can you change the delete script to allow defining beginning and end dates?
0
 
TheNetworkPro15Author Commented:
Excellent! Thank you for your expert assistance.
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
Not a problem, glad to help!

Will.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.