AutomoxAutomox

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

owl-IT
September 17, 2019 at 10:02 pm UTC
19 lines
<#
.SYNOPSIS
Check for presence of Microsoft Mail App on Managed laptops

.DESCRIPTION

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

.NOTES
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, Outlook.com, Gmail,
Yahoo! and other popular accounts.

.LINK
https://www.microsoft.com/en-ca/p/mail-and-calendar/9wzdncrfhvqm?activetab=pivot:overviewtab

#>

EVALUATION Code

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

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

REMEDIATION CODE

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

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (6)

jermicideFebruary 26, 2020
#1

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

MinnesotaJoeFebruary 26, 2020
#2

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.

Nic-AutomoxFebruary 26, 2020
#3

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

Nic-AutomoxFebruary 26, 2020
#4

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.

jermicideFebruary 26, 2020
#5

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.

Nic-AutomoxFebruary 26, 2020
#6

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.