使用PowerShell批量删除特定邮箱中“inbox”文件夹中的所有电子邮件

时间:2015-08-26 12:30:54

标签: powershell directory exchange-server bulk

我正在尝试删除名为“GTV Info”的特定邮箱的“收件箱”文件夹中的48000封电子邮件。我只想删除“收件箱”文件夹中的所有电子邮件,并将“收件箱”文件夹保留为空。

Exchange Server 2007 SP1 08.01.0436.000

我发出此命令,这是我收到的错误消息:

[PS] C:\Windows\system32>Export-Mailbox -Identity "GTV Info"
-IncludeFolders "\Inbox" -StartDate "16/11/2009" -EndDate "24/08/2011" -DeleteContent

Confirm Are you sure you want to perform this action? Searching the contents and/or the associated messages from the mailbox 'GTV Info' and deleting those messages that meet the criteria specified. This operation may take a long time to complete. [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):A Export-Mailbox : Error was found for GTV Info (info@gt-vehicles.com) because: E rror occurred in the step: Moving messages. Failed to copy messages to the dest ination mailbox store with error: MAPI or an unspecified service provider. ID no: 00000000-0000-00000000, error code: -1056749164 At line:1 char:15
+ Export-Mailbox <<<<  -Identity "GTV Info" -IncludeFolders "\Inbox" -StartDate  "16/11/2009" -EndDate "24/08/2011" -DeleteContent
    + CategoryInfo          : InvalidOperation: (0:Int32) [Export-Mailbox], Re    cipientTaskException
    + FullyQualifiedErrorId : 35CD2975,Microsoft.Exchange.Management.Recipient    Tasks.ExportMailbox



Identity                         : gtv.local/MyBusiness/Users/SBSUsers/GTV Info DistinguishedName         : CN=GTV Info,OU=SBSUsers,OU=Users,OU=MyBusine
                                   ss,DC=gtv,DC=local DisplayName                      : GTV Info Alias                            : info LegacyExchangeDN    : /o=First Organization/ou=Exchange Administra
                                   tive Group (FYDIBOHF23SPDLT)/cn=Recipients/c
                                   n=info PrimarySmtpAddress               : info@gt-vehicles.com SourceServer                     : SAGITARIUS.gtv.local SourceDatabase                   : SAGITARIUS\First Storage Group\Mailbox Datab
                                   ase SourceGlobalCatalog              : SAGITARIUS SourceDomainController           : TargetGlobalCatalog    : SAGITARIUS TargetDomainController           : TargetMailbox          : TargetServer                     : TargetDatabase                   : MailboxSize                      : 1928KB IsResourceMailbox          : False SIDUsedInMatch                   : SMTPProxies                 : SourceManager                    : SourceDirectReports              : SourcePublicDelegates            : SourcePublicDelegatesBL          : SourceAltRecipient               : SourceAltRecipientBL             : SourceDeliverAndRedirect         : MatchedTargetNTAccountDN         : IsMatchedNTAccountMailboxEnabled : MatchedContactsDNList            : TargetNTAccountDNToCreate        : TargetManager                    : TargetDirectReports              : TargetPublicDelegates            : TargetPublicDelegatesBL          : TargetAltRecipient               : TargetAltRecipientBL             : TargetDeliverAndRedirect         : Options                          : DeleteSourceContent SourceForestCredential           : TargetForestCredential           : TargetFolder                     : PSTFilePath                      : RsgMailboxGuid                   : RsgMailboxLegacyExchangeDN       : RsgMailboxDisplayName            : RsgDatabaseGuid                  : StandardMessagesDeleted          : 0 AssociatedMessagesDeleted        : 0 DumpsterMessagesDeleted          : 0 MoveType                      : DeleteOnly MoveStage                        : Move StartTime         : 26/08/2015 13:12:15 EndTime                          : 26/08/2015 13:12:16 StatusCode                       : -1056749164 StatusMessage  : Error occurred in the step: Moving messages.
                                    Failed to copy messages to the destination
                                   mailbox store with error:
                                   MAPI or an unspecified service provider.
                                   ID no: 00000000-0000-00000000 ReportFile                       : C:\Program Files\Microsoft\Exchange Server\L
                                   ogging\MigrationLogs\export-Mailbox20150826-
                                   131211-5306000.xml



[PS] C:\Windows\system32>

我非常坚持这一点,我真的需要来自这个令人敬畏的社区的帮助。

1 个答案:

答案 0 :(得分:1)

在您的命令中,您缺少将电子邮件导出到的目的地。

你没有工作的命令:

Export-Mailbox -Identity "GTV Info" -IncludeFolders "\Inbox" -StartDate "16/11/2009" -EndDate "24/08/2011" -DeleteContent

定义了目的地后,它看起来像这样:

Export-Mailbox -Identity "GTV Info" -IncludeFolders "\Inbox" -StartDate "16/11/2009" -EndDate "24/08/2011" -DeleteContent -PSTFolderPath 'C:\PSTFiles\Mails.pst'

有关示例,请参阅here,有关可用参数的详细信息,请参见here