Having problem with search-mailbox cmdlet

%3CLINGO-SUB%20id%3D%22lingo-sub-223840%22%20slang%3D%22en-US%22%3EHaving%20problem%20with%20search-mailbox%20cmdlet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-223840%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20work%20with%20the%20Search-Mailbox%20cmdlet%20to%20copy%20email%20from%20one%20user%20to%20another.%3C%2FP%3E%3CP%3EI%20start%20a%20PS%20windows%20as%20Admin.%3C%2FP%3E%3CP%3EConnect%20to%20O365%3C%2FP%3E%3CP%3E%3CEM%3EImport-Module%20MSOnline%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%24cred%20%3D%20Get-Credential%20-Message%20'enter%20info'%20-UserName%20'XXXX%20MY%20User%20XXXX'%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EConnect-MsolService%20-Credential%20%24cred%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20set%20some%20variables%20and%20use%20this%20command%3C%2FP%3E%3CP%3E%3CEM%3ESearch-Mailbox%20%24SourceUserName%20-TargetMailbox%20%22%24TargetUserName%22%20-TargetFolder%20%22%24TargetFolderName%3D%22%20-LogLevel%20Full%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20this%20response%20back%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESearch-Mailbox%20%3A%20The%20term%20'Search-Mailbox'%20is%20not%20recognized%20as%20the%20name%20of%20a%20cmdlet%2C%20function%2C%20script%20file%2C%20or%3CBR%20%2F%3Eoperable%20program.%20Check%20the%20spelling%20of%20the%20name%2C%20or%20if%20a%20path%20was%20included%2C%20verify%20that%20the%20path%20is%20correct%20and%20try%3CBR%20%2F%3Eagain.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20check%20the%20O365-Exchange%20admin%20center%20and%20I%20am%20a%20member%20of%20the%20Discovery%20Management%20group%20%2F%20admin%20roles.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20now%20I%20am%20out%20of%20guesses.%20I%20simply%20don't%20have%20the%20cmdlet%20available.%20Is%20there%20a%20module%20I%20am%20suppose%20to%20load%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-223840%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-224139%22%20slang%3D%22en-US%22%3ERe%3A%20Having%20problem%20with%20search-mailbox%20cmdlet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-224139%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20need%20to%20be%20a%20member%20of%20the%20Mailbox%20Import%20Export%20or%20the%20Mailbox%20Search%26nbsp%3Brole%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EGet-ManagementRole%20-Cmdlet%20Search-Mailbox%20-CmdletParameters%20TargetMailbox%0A%0AName%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20RoleType%0A----%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20--------%0AMailbox%20Import%20Export%20MailboxImportExport%0AMailbox%20Search%20%20%20%20%20%20%20%20MailboxSearch%0A%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Highlighted
Visitor

I am trying to work with the Search-Mailbox cmdlet to copy email from one user to another.

I start a PS windows as Admin.

Connect to O365

Import-Module MSOnline
$cred = Get-Credential -Message 'enter info' -UserName 'XXXX MY User XXXX'
Connect-MsolService -Credential $cred

 

I set some variables and use this command

Search-Mailbox $SourceUserName -TargetMailbox "$TargetUserName" -TargetFolder "$TargetFolderName=" -LogLevel Full

 

I get this response back:

Search-Mailbox : The term 'Search-Mailbox' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.

 

 

I check the O365-Exchange admin center and I am a member of the Discovery Management group / admin roles.

 

So now I am out of guesses. I simply don't have the cmdlet available. Is there a module I am suppose to load?

 

 

1 Reply
Highlighted

You need to be a member of the Mailbox Import Export or the Mailbox Search role:

 

Get-ManagementRole -Cmdlet Search-Mailbox -CmdletParameters TargetMailbox

Name                  RoleType
----                  --------
Mailbox Import Export MailboxImportExport
Mailbox Search        MailboxSearch