Forum Discussion
Missing Search-Mailbox Command in my imported session
I was asked today by a colleage to search ( and delete) and email sent accidently by one of the managers to mulple recipients.
To do this in Exchange Online: PowerShell I normally open a remote session to access the necessary commands
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ` https://outlook.office365.com/powershell-liveid/ -Credential $cred ` -Authentication Basic -AllowRedirection
I am import my session .. and look for my Search commands
Get-Command -Module $tmpModule.Name -Name "Search*"
CommandType Name Version Source
----------- ---- ------- ------
Function Search-AdminAuditLog 1.0 tmp_XXXX
Function Search-MailboxAuditLog 1.0 tmp_XXXX
Function Search-MessageTrackingReport 1.0 tmp_XXXX
Function Search-UnifiedAuditLog 1.0 tmp_XXXX
No Search-Mailbox commmand to be found :-(. I then went and got myself added to the descovery Manager in the Exchange online, closed and reopened my exhange session but sill my command is missing. Has anybody resolved this?
You need to be a member of one of the following Roles:
[21:18:56][O365]# Get-ManagementRole -Cmdlet Search-Mailbox
Name RoleType
---- --------
Mailbox Import Export MailboxImportExport
Mailbox Search MailboxSearchAdd yourself, reload the cmdlets and you should be good to go.
Use Search-Malbox with care btw, one typo and you're updating your CV... :)
5 Replies
You need to be a member of one of the following Roles:
[21:18:56][O365]# Get-ManagementRole -Cmdlet Search-Mailbox
Name RoleType
---- --------
Mailbox Import Export MailboxImportExport
Mailbox Search MailboxSearchAdd yourself, reload the cmdlets and you should be good to go.
Use Search-Malbox with care btw, one typo and you're updating your CV... :)
- Daniel WesterdaleIron Contributor
VasilMichev wrote:You need to be a member of one of the following Roles:
[21:18:56][O365]# Get-ManagementRole -Cmdlet Search-Mailbox
Name RoleType
---- --------
Mailbox Import Export MailboxImportExport
Mailbox Search MailboxSearchAdd yourself, reload the cmdlets and you should be good to go.
Use Search-Malbox with care btw, one typo and you're updating your CV... :)
VasilMichev thanks for the advice. I started reading through the technet PS documentation yesterday. Then I realised yesterday I got a colleague to add me to the Discovery managment Group.
I had initially tested with a new session and the commandlet wasn't apparent. Having retested and I now have my Search-mailbox commandlet ( which is why I marked this thread as answered) . .However, things are not so simple ..........
Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {Subject:"Wy I need to update my CV*"}
The target mailbox or .pst file path is required.
+ CategoryInfo : InvalidArgument: (:) [], ArgumentException
+ FullyQualifiedErrorId : [Server=HE1PR0501MB2716,RequestId=a57a686e-e78b-4bb5-9685-dfc3fe05f276,TimeSt
amp=26/04/2017 14:38:35] [FailureCategory=Cmdlet-ArgumentException] 8C2A5F3A
+ PSComputerName : outlook.office365.comRightly or wrongly I assumed that maybe I needed to have delegated permissions for each mailbox - can I undo this if this isn't necessary
Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')} | Add-MailboxPermission -User darth.vader@deathstar.onmicrosoft.com -AccessRights FullAccess -InheritanceType all
However, I still don't get passed the error shown above.
You need to provide a (discovery) mailbox to store the results in, this is done via the -TargetMailbox and -TargetFolder parameters. Alaternatively, you can use eDiscovery from the UI, which gives you the option to Preview search results without copying them to a mailbox.