Applies to: Exchange Server 2013
Topic Last Modified: 2012-10-16
Use the Search-Mailbox cmdlet to search a mailbox and copy the results to a specified target mailbox, delete messages from the source mailbox, or both.
Syntax
Search-Mailbox -TargetFolder <String>
-TargetMailbox <MailboxIdParameter> [-DeleteContent
<SwitchParameter>] [-LogLevel <Suppress | Basic |
Full>] [-LogOnly <SwitchParameter>] <COMMON
PARAMETERS>
|
Search-Mailbox [-DeleteContent <SwitchParameter>]
<COMMON PARAMETERS>
|
Search-Mailbox -EstimateResultOnly
<SwitchParameter> <COMMON PARAMETERS>
|
COMMON PARAMETERS: -Identity
<MailboxOrMailUserIdParameter> [-Confirm
[<SwitchParameter>]] [-DomainController <Fqdn>]
[-DoNotIncludeArchive <SwitchParameter>] [-Force
<SwitchParameter>] [-IncludeUnsearchableItems
<SwitchParameter>] [-SearchDumpster <SwitchParameter>]
[-SearchDumpsterOnly <SwitchParameter>] [-SearchQuery
<String>] [-WhatIf [<SwitchParameter>]]
|
Examples
EXAMPLE 1
This example searches the mailbox of Joe Healy and copies the search results to the DiscoveryMailbox in the folder JoeHealy-ProjectHamilton.
Copy Code | |
---|---|
Search-Mailbox -Identity "Joe Healy" -SearchQuery "Subject:Project Hamilton" -TargetMailbox "DiscoveryMailbox" -TargetFolder "JoeHealy-ProjectHamilton" -LogLevel Full |
EXAMPLE 2
This example searches April Stewart's mailbox for messages that contain the phrase "Your bank statement" in the subject and logs the result in the SearchAndDeleteLog folder in the administrator's mailbox. Messages aren't copied to the target mailbox.
Copy Code | |
---|---|
Search-Mailbox -Identity "April Stewart" -SearchQuery 'Subject:"Your bank statement"' -TargetMailbox "administrator" -TargetFolder "SearchAndDeleteLog" -LogOnly -LogLevel Full |
EXAMPLE 3
This example searches April Stewart's mailbox for messages that contain the phrase "Your bank statement" in the subject and deletes the messages from the source mailbox.
Copy Code | |
---|---|
Search-Mailbox -Identity "April Stewart" -SearchQuery 'Subject:"Your bank statement"' -DeleteContent |
EXAMPLE 4
This example searches all mailboxes in your organization for messages that contain the words "election", "candidate", or "vote". The search results are copied to the Discovery Search Mailbox in the folder AllMailboxes-Election.
Copy Code | |
---|---|
Get-Mailbox | Search-Mailbox -SearchQuery 'election OR candidate OR vote' -TargetMailbox "Discovery Search Mailbox" -TargetFolder "AllMailboxes-Election" -LogLevel Full |
Detailed Description
You can use the Search-Mailbox cmdlet to search messages in a specified mailbox and perform any of the following tasks:
- Copy messages to a specified target mailbox.
- Delete messages from the source mailbox.
- Copy messages from the source mailbox and delete them from the
target mailbox.
- Perform single item recovery to recover items from a user's
Recoverable Items folder.
- Clean up the Recoverable Items folder for a mailbox when it has
reached the Recoverable Items hard quota.
You need to be assigned permissions before you can run this cmdlet. Although all parameters for this cmdlet are listed in this topic, you may not have access to some parameters if they're not included in the permissions assigned to you. To see what permissions you need, see the "Multi-Mailbox Search" entry in the Messaging Policy and Compliance Permissions topic.
Parameters
Parameter | Required | Type | Description | ||
---|---|---|---|---|---|
EstimateResultOnly |
Required |
System.Management.Automation.SwitchParameter |
The EstimateResultOnly switch specifies that only an estimate of the total number and size of messages returned by the search be provided. Messages aren't copied to the target mailbox. You can't use this switch with the TargetMailbox parameter. |
||
Identity |
Required |
Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter |
The Identity parameter specifies the identity of the mailbox to search. This parameter accepts the following values:
|
||
TargetFolder |
Required |
System.String |
The TargetFolder parameter specifies a folder name in which search results are saved in the target mailbox. The folder is created in the target mailbox upon execution. |
||
TargetMailbox |
Required |
Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter |
The TargetMailbox parameter specifies the identity of the destination mailbox where search results are copied. You can use the following values:
When you specify a value for the TargetMailbox parameter, you must also specify the TargetFolder parameter. You can't use this parameter with the EstimateResultOnly switch. |
||
Confirm |
Optional |
System.Management.Automation.SwitchParameter |
The Confirm switch causes the command to pause processing and requires you to acknowledge what the command will do before processing continues. You don't have to specify a value with the Confirm switch. |
||
DeleteContent |
Optional |
System.Management.Automation.SwitchParameter |
The DeleteContent switch specifies that the messages
returned by the search be permanently deleted from the source
mailbox. When used with the TargetMailbox parameter,
messages are copied to the target mailbox and removed from the
source mailbox. If you set the logging level for the search to
|
||
DomainController |
Optional |
Microsoft.Exchange.Data.Fqdn |
The DomainController parameter specifies the fully qualified domain name (FQDN) of the domain controller that writes this configuration change to Active Directory. |
||
DoNotIncludeArchive |
Optional |
System.Management.Automation.SwitchParameter |
The DoNotIncludeArchive switch specifies that the user's archive mailbox shouldn't be included in the search. You don't need to specify a value for this switch. |
||
Force |
Optional |
System.Management.Automation.SwitchParameter |
The Force switch overrides the confirmation prompt displayed when your use the DeleteContent switch to permanently delete messages. |
||
IncludeUnsearchableItems |
Optional |
System.Management.Automation.SwitchParameter |
The IncludeUnsearchableItems switch specifies whether to
include items that couldn't be indexed by Exchange Search. When set
to |
||
LogLevel |
Optional |
Microsoft.Exchange.Data.Storage.Infoworker.MailboxSearch.LoggingLevel |
The LogLevel parameter specifies the logging level for the search. It can have one of the following values:
The default log level is |
||
LogOnly |
Optional |
System.Management.Automation.SwitchParameter |
The LogOnly switch specifies that a search be performed and only a log be generated. Messages returned by the search aren't copied to the target mailbox. The logging level is specified by using the LogLevel parameter. |
||
SearchDumpster |
Optional |
System.Management.Automation.SwitchParameter |
The SearchDumpster parameter specifies whether to search
the Recoverable Items folder, which is the storage location in
which items deleted from the Deleted Items folder or hard-deleted
items are stored until they're purged from the mailbox database. By
default, the Recoverable Items folder is always searched. To
exclude the folder from the search, set the SearchDumpster
switch to |
||
SearchDumpsterOnly |
Optional |
System.Management.Automation.SwitchParameter |
The SearchDumpsterOnly switch specifies that only the Recoverable Items folder of the specified mailbox be searched. You can also use this switch with the DeleteContent switch to delete messages from the Recoverable Items folder and reduce the size of the folder. |
||
SearchQuery |
Optional |
System.String |
The SearchQuery parameter specifies a search string or a query formatted using Keyword Query Language (KQL). For more details about KQL, see Keyword Query Language syntax reference. If this parameter is empty, all messages are returned. |
||
WhatIf |
Optional |
System.Management.Automation.SwitchParameter |
The WhatIf switch instructs the command to simulate the actions that it would take on the object. By using the WhatIf switch, you can view what changes would occur without having to apply any of those changes. You don't have to specify a value with the WhatIf switch. |
Input Types
To see the input types that this cmdlet accepts, see Cmdlet Input and Output Types. If the Input Type field for a cmdlet is blank, the cmdlet doesn’t accept input data.
Return Types
To see the return types, which are also known as output types, that this cmdlet accepts, see Cmdlet Input and Output Types. If the Output Type field is blank, the cmdlet doesn’t return data.