×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PowerShell

Export a Single Mailbox by markdmac
Posted: 14 Aug 14

CODE


#==========================================================================
#
# Script: ExportMailbox.ps1
#
# AUTHOR:  Mark D. MacLachlan, The Spider's Parlor 
# Date: 01/14/2014 
#
#    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
#    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
#    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
#    PARTICULAR PURPOSE.
#
#    IN NO EVENT SHALL THE SPIDERS PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
#    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
#    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
#    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
#    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
#    OF THIS CODE OR INFORMATION.
#
#
# COMMENT: 
#   
#
#==========================================================================

#Get the alias name
$Alias = Read-Host "Enter mailbox name"

#Show the user the mailbox size
$MailboxSize = Get-MailboxStatistics -Identity $Alias | where {$_.ObjectClass ûeq ôMailboxö} | Sort-Object TotalItemSize ûDescending | ft @{label=öUserö;expression={$_.DisplayName}},@{label=öTotal Size (GB)ö;expression={$_.TotalItemSize.Value.ToGB()}},@{label=öItemsö;expression={$_.ItemCount}} -auto
Write-Host $MailboxSize

#Get the path to create the PST in
$PSTPath = Read-Host "Enter PST Path (MUST BE A UNC PATH)"

#Get the  PST name
$PSTName = Read-Host "Enter PST Name"

#Check if PST ends in .PST, add it if not.
If($PSTName.Length -lt 4)
{$PSTName = $PSTName + ".pst"}
$EndPST = $PSTName.substring($PSTName.length - 4, 4)
If($EndPST -eq ".pst")
{$PSTName = $PSTName}
Else
{$PSTName = $PSTName + ".pst"}

#Check if the PSTPath ends in a slash or not, add it if needed and join with PST name
$EndSring = $PSTPath.substring($PSTPath.length - 1, 1)
If($EndString -eq "\")
{$FullPSTPath = $PSTPath + $PSTName}
Else
{$FullPSTPath = $PSTPath + "\" + $PSTName}


#Check how many bad items are allowed
$BadAllowed = Read-Host "Enter number of allowed bad items -recommended 150"

#Specify if we need a date range to export of not.
$SelectDate = Read-Host "Select a date range? Y or N")


#Now execute the export request
If($SelectDate -eq "y")
{
#Get date ranges
$StartRange = Read-Host "Enter Start Date  MM/DD/YYYY"
$EndRange = Read-Host "Enter End Date  MM/DD/YYYY"
#Make it so
New-MailboxExportRequest -ContentFilter {(Received -lt "$EndRange") -and (Received -gt "StartRange")} -Mailbox $Alias -FilePath "$FullPSTPath"-BadItemLimit $BadAllowed -AcceptLargeDataLoss
}
Else
{
#Make it so
New-MailboxExportRequest -Mailbox $Alias -FilePath "$FullPSTPath"-BadItemLimit $BadAllowed -AcceptLargeDataLoss
} 

Back to Microsoft: Exchange FAQ Index
Back to Microsoft: Exchange Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close