The term ‘Search-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program

In this blog I will share How to Fix The term ‘Search-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program error.

 

This error occurs when you run the command Search-Mailbox in a windows PowerShell which is not connected to Exchange Online.

 

Search-Mailbox Command is also used on Exchange on-Premise. If you are getting this error, make sure you are on the correct windows server which has Exchange Running and you are running the command on Exchange Management Shell and not the Windows PowerShell.

 

Windows PowerShell is used when you are running the Search-Mailbox command to search the mailbox which is on Exchange Online.

 

In this Article we will talk about the error in regards to Exchange Online.

 

When we run the command in the PowerShell which is not connected to exchange Online we get the following error:

The term 'Search-Mailbox' is not recognized

To fix The term ‘Search-Mailbox’ is not recognized error follow the steps:

Open your Windows PowerShell as an Administrator on your computer and connect it to Exchange online using this article.

 

Once connected without error, you should be able to run the command.

 

Below is the syntax of the Search-Mailbox command:

Search-Mailbox
[-Identity]
[-TargetFolder]
[-TargetMailbox]
[-Confirm]
[-DeleteContent]
[-DomainController ]
[-DoNotIncludeArchive]
[-Force]
[-IncludeUnsearchableItems]
[-LogLevel ]
[-LogOnly]
[-SearchDumpster]
[-SearchDumpsterOnly]
[-SearchQuery ]
[-WhatIf]

 

You have to be assigned the Mailbox Import Export management role to use the  DeleteContent switch.

 

Below is Example for the above command:

 

Search-Mailbox -Identity "Prem S" -SearchQuery 'Subject:"Your bank statement"' -TargetMailbox "administrator" -TargetFolder "SearchResultsFound" -LogOnly -LogLevel Full

 This example searches Prem S mailbox for messages that contain the phrase “Your bank statement” in the subject and logs the result in the SearchResultsFound folder in the administrator’s mailbox. Only logs are copied, Messages aren’t copied to the target mailbox.

 

To know more about the Search-Mailbox command refer Official Microsoft Post.

 

If you have any question, do let me know in the comment section below.

 

Date:2705/2023

Author: Prem

Tag: The term ‘Search-Mailbox’ is not recognized

Leave a Comment

Your email address will not be published. Required fields are marked *