Link to home
Start Free TrialLog in
Avatar of Christian Hans
Christian HansFlag for United States of America

asked on

Powershell - Delete Outlook Task from multiple user mailboxes

Is there a way to administratively run a PowerShell script to delete a specific Outlook Task sent out to a subset of users?  

Thanks in advance.
Avatar of Adam the 32-bit Aardvark
Adam the 32-bit Aardvark
Flag of Poland image

You can use the Search-Mailbox cmdlet to delete multiple Outlook elements, such as tasks. The following article shows you how to do it: How to delete email from mailboxes on Exchange 2016 / 2013 / 2010 / Online
In short, you can use the following cmdlet for your purposes:
foreach ($mailbox in (get-mailbox)) {Search-Mailbox -id $mailbox -SearchQuery '(kind:tasks) AND (subject:#keyword#)' -DeleteContent -Force}

Open in new window

Before you run this command, check if it returns the results you are looking for by replacing -DeleteContent - Force with the -EstimateResultsOnly
Avatar of Christian Hans

ASKER

Thanks for the assist, unfortunately I get this result:

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "lastname, firstname" value of type
"Deserialized.Microsoft.Exchange.Data.Directory.Management.Mailbox" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
    + CategoryInfo          : InvalidData: (:) [Search-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Search-Mailbox
    + PSComputerName        : ps.outlook.com
ASKER CERTIFIED SOLUTION
Avatar of Adam the 32-bit Aardvark
Adam the 32-bit Aardvark
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial