Script to block Outlook/Mail if Hexnode agent isn’t installed?Solved

Participant
Discussion
5 months ago Nov 02, 2025

Hey everyone. Management wants to completely lock down our corporate email. They only want users to be able to access the Outlook app (or native Mail apps) on their laptops and phones if the device has the Hexnode Agent/App installed and is actively managed by us. 

We have a massive mix of Windows, Android, and iOS devices. I was initially thinking of writing some kind of custom script to check for the agent’s presence and kill the mail app if it’s missing, but that sounds like an absolute nightmare to maintain across three different operating systems. 

Has anyone found a clean workaround or have a script for this specific use-case? 

Replies (1)

Marked SolutionPending Review
Participant
5 months ago Nov 04, 2025
Marked SolutionPending Review

Do not try to script this. Writing a local script to block a cloud app like Outlook is going to be incredibly messy, easily bypassed by smart users, and practically impossible to execute cleanly on non-jailbroken iOS/Android devices anyway.

The industry-standard (and much more reliable) way to handle this is by using Microsoft Entra ID (formerly Azure AD) Conditional Access.

Since you are already using Hexnode and Office 365, you can just tie them together. You basically tell Entra ID to use hexnode as its source of truth for device health.

This is basically how it works (if you check the Hexnode help center, you can find the detailed docs for this integration, but here is the gist):

  1. Set up your Compliance Policy: In your Hexnode console, go to Policies > Compliance policy > New policy and select your platform (Windows, Android, or iOS). Under the Basic settings, check the boxes that mark the device as “Non-compliant” if the MDM profile or the Hexnode app is removed. Save it and make sure to associate this policy with your target devices.
  2. Link the Platforms: Set up the Microsoft entra conditional access integration within Hexnode. This allows hexnode to continuously report the real-time compliance status of your devices directly to Entra ID.
  3. Create the Block: Head over to your Microsoft entra portal and create a new Conditional access policy. Target your Office 365/exchange apps, and under the Grant controls, select “Require device to be marked as compliant”.

If a user tries to download Outlook on their personal iPad and sign in, entra ID will check with Hexnode, see the device isn’t registered/compliant, and immediately block the login at the cloud level. No messy local scripts required!

Save