pramod1
asked on
outlook, powershell
I am trying to run
search-mailbox -Identity "user@domain.com" -SearchQuery subject:"credit card" -DeleteContent
but it says search-mailbox is not recognized as name of commandlet
I have outlook 2010 and running on powershell connected to office 365 user mailboxes
search-mailbox -Identity "user@domain.com" -SearchQuery subject:"credit card" -DeleteContent
but it says search-mailbox is not recognized as name of commandlet
I have outlook 2010 and running on powershell connected to office 365 user mailboxes
ASKER
I am already connected to o365 command doesn't work
ASKER
I want to delete something which has come in subject from the user's mailbox, what command should I use
ASKER
Search-Mailbox -Identity "April Stewart" -SearchQuery 'Subject:"Your bank statement"' -DeleteContent -not working
ASKER
Can you double check to ensure that your account is a member of the "Discovery Management" role? If your account is not part of this role, then the search-mailbox cmdlet is not imported. If you need to add your account to this role, you can do so through ECP, then restart your powershell session to connect with the proper credentials, and import these commands.
Hope this helps!
Christopher.
Hope this helps!
Christopher.
ASKER
where should I check, I am in exchange admin center
ASKER
under -permission-admin roles-discovery management?
"Exchange Admin Center"
"Permissions"
"Admin Roles"
"Discovery Management"
Edit, and make sure your account is a member.
"Permissions"
"Admin Roles"
"Discovery Management"
Edit, and make sure your account is a member.
ASKER
ok let me try
ASKER
I added myself as member but not working, do I need to connect back again
Yes, after adding yourself as a member, you must reconnect to office 365 exchange powershell, to import the missing cmdlets.
Christopher.
Christopher.
ASKER
do I need to member of any other group as it not working
ASKER
I am global admin also
Discovery Management is the only role you should need to add yourself to.... Are you in a hybrid environment?
To double check in your enviroment, you could run these commands:
It will tell you what Roles you need.
$perms = Get-ManagementRole -Cmdlet search-mailbox
and $perms | foreach {Get-ManagementRoleAssignment -role $_.name -Delegating $False |Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}
It will tell you what Roles you need.
Because you're trying to delete content, with the search-mailbox command, I looked up the permissions needed for both together, this is what I found:
https://notesbytom.wordpress.com/2015/02/11/permissions-required-for-search-mailbox-and-deletecontent/
Christopher.
https://notesbytom.wordpress.com/2015/02/11/permissions-required-for-search-mailbox-and-deletecontent/
Christopher.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I guess I should've posted the information here, instead of the link.
I'll know better for next time.
Glad you've got a working solution pramod1.
I'll know better for next time.
Glad you've got a working solution pramod1.
Are you connecting to office 365 exchange before running this command?
See here for connecting:
https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
Also, the example provided here uses single quotes around the subject:"credit card" part of the command:
https://o365info.com/using-the-search-mailbox-powershell-command-introduction-part-1-5/
So your command would look like this:
Open in new window
Hope this helps!
Christopher.