SearchMailboxes.ps1 is a script to run a discovery search (using Exchange 2010's Multi-Mailbox Search) periodically on a set of mailboxes. The script works only with Microsoft Exchange 2010 SP1. Please note, Multi-mailbox Search is an Enterprise CAL feature.
This script runs a discovery search on the specified mailboxes over a period of time. To learn more about discovery, see Understanding Multi-Mailbox Search.
The package contains the following files:
Setup.bat: This creates a scheduled task using the Schtasks command. It's configured to run once a week (on Monday). You can edit the file to configure the frequency at which you want to run the script. You can also modify the scheduled task using the Task Scheduler - see Schedule a Task for more info.
DailyMailboxSearch.bat: This is the batch file that the schedule task runs. Edit it to specify the path to exshell.psc1 (the default path is \Program Files\Microsoft\Exchange Server\V14\Bin\). To run a Shell (<acronym title="Exchange Management Shell">EMS</acronym>) script on a schedule using the Windows Task Scheduler, you must call the Shell and include the script that you want to run as a parameter. For more details, see Scripting with the Exchange Management Shell.
powershell -PSConsoleFile "d:\Program Files\Microsoft\Exchange Server\V14\Bin\exshell.psc1" -command ".\SearchMailboxes.ps1 "
# Name of the mailboxes accepts all the types of mailbox names that can be specified to get-mailbox cmdlet
# ex: SearchMailboxes.ps1 user1
# ex: SearchMailboxes.ps1 user*
# ex: SearchMailboxes.ps1 *user*
Search.Config: Open Search.Config and edit the value of Discovery mailbox. This command gets the Discovery mailbox:
Get-Mailbox -Identity Discovery*
LastSearch.txt: This file is generated when the SearchMailboxes.ps1 script is run for the first time. It stores the information about the last time the search was run. If this file isn't present, the SearchMailboxes.ps1 script will pick the start date of the search from the Search.config file.
SearchMailboxes.ps1: This is the script that consumes search.config and lastSearch.txt to generate the search results. It's not required to modify this script because all configurable parameters are contained in the other files in this list.
For more information on this download and how to use it, see: http://blogs.technet.com/b/exchange/archive/2010/11/29/3411613.aspx