Friday, January 1, 2016

[EX2010] Search Mailbox


Need to assign the management Roles to perform the search-mailbox for the user account from which we are running the cmdlet in exchange 2010 SP1 or greater


Roles:
Mailbox Import Export
Mailbox Search

example:
new-managementroleassignment -Name "test" -role "Mailbox Import Export" -User "username"
new-managementroleassignment -Name "test1" -role "Mailbox Search" -User "username" 


1)To search the emails older than 01/26/2011 from a particular user's mailbox
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’

2)To search the emails older that 01/01/2011 from a perticluar user's mailbox and delete them.
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’ -DeleteContent -Force  

3)To search the emails from the specific mailbox database which are older than 01/26/2011.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’

4)To search the emails from the specific mailbox database which are older than 01/26/2011 and delete them.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

5)To delete messages from all the users on a server which are older than 01/26/2011.
Get-mailbox –server “servername” –resultsize unlimited | Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

6)To search the emails from the specific mailbox database from a perticlar folder in the mailbox
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘In:"folder name"

7)Below example searches the mailbox of myuser and copies the search results to the DiscoveryMailbox in the folder my_user_data.
Search-Mailbox -Identity myuser -SearchQuery 'Subject:”project report”' -TargetMailbox "DiscoveryMailbox" -TargetFolder my_user_data

8)Below example searches Myuser's mailbox for messages that contain the words "project details" in the subject and deletes the messages from the source mailbox.
Search-Mailbox -Identity "Myuser" -SearchQuery 'Subject:"project details"' -DeleteContent
 Note: you can add the delete content at the end to delete all the searched content.

Please find the some key list of AOS search.
To Restrict by File Type:                Use                                        Example
All file types                                 everything                          kind:everything
Communications                           communications                 kind:communications
Contacts                                      contacts                               kind:contacts
E-mail                                         email                                     kind:email
Instant Messenger                        conversations im                    kind:im
Meetings                                      meetings                             kind:meetings
Tasks                                           tasks                                      kind:tasks
Notes                                           notes                                    kind:notes
Documents                                   docs                                       kind:docs
Text documents                            text                                        kind:text
Spreadsheets                               spreadsheets                    kind:spreadsheets
Presentations                               presentations                    kind:presentations
Music                                          music                                    kind:music
Pictures                                       pics                                        kind:pics
Videos                                         videos                                   kind:videos
Folders                                        folders                                  kind:folders
Folder name                                 foldername or in              foldername:mydocs or in:mydocs
Favorites                                      favorites                              kind:favorites

Programs                                     programs                             kind:programs