Worklet: Remove Microsoft Mail App from Managed laptops - Windows 10

Check for presence of Microsoft Mail App on Managed laptops


Exits with 0 for compliance, 1 for Non-Compliance.
Non-Compliant devices will run Remediation Code at the Policy's next scheduled date.

The Mail and Calendar apps help you stay up to date on your email, manage your schedule and stay in touch
with people you care about the most. Designed for both work and home, these apps help you communicate quickly
and focus on what’s important across all your accounts. Supports Office 365, Exchange,, Gmail,
Yahoo! and other popular accounts.




$App = Get-AppxPackage Microsoft.windowscommunicationsapps | Select-Object Status

if ( $App -eq 'NULL' ) {
   Exit 0
} else { Exit 1 }


# This code execution will REMOVE the MS Mail app from the managed laptop
Get-AppxPackage Microsoft.windowscommunicationsapps | Remove-AppxPackage

is there a means of reporting if/when remediation occurs? if/when evaluation finds app is not installed?

I would recommend editing your post and converting it into ‘code’.
Highlight all of your code and hit Control+Shift+C or click the button in the toolbar.
It will make reading the code easier.

Thanks for catching that @MinnesotaJoe - I went in and added the code blocks to make it easier to read and copy.

Remediation results will show in the Activity Log. Evaluations don’t show up, but you can manually put in code to output to STDERR and that will show up in the Activity Log. We are planning on improving the reporting and visibility into the code execution, but for now this is the best workaround.

As best I can tell, a STDERR would have to be pursued (an admin would have to go find it vs be told it occurred?). Correct?

If you allow Zawinski’s law of software envelopment (also known as Zawinski’s law ) to influence this dialog:

Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.

Would it be nonsensical to script the remediation block to send an email notification on occurance?

BTW: I think Zawinski’s law is ridiculous.

1 Like

Yes it is something that you’d have to go look for, unless you used the API to parse the activity log and take some action when it discovers that a worklet has completed. You could have the remediation block send an email, or use some other notification method, if you need to be alerted when it’s finished running on a device. Just remember that the remediation block runs as System on the local machine, so you’d need to take that into account when selecting and implementing your notification method.