Can I run a script when a User establishes a Zero Trust Connection on Windows?

I was wondering if it was possible to run a script that maps Network drives whenever a User toggles Zero Trust on his machine.

I would need the following things for this - probably right from the Client machine:

  1. I somehow need to be able to catch the “toggle”. Is there an event or something that happens when someone toggles Zero Trust?
  2. It would be nice to know the user that toggles Zero Trust, preferrably the E-Mail Address. Is there a way to do this?


Unfortunately, Cloudflare Tunnel and its associated Zero Trust networking model does not currently support triggering scripts or exporting user information when a connection is established. It primarily functions as a secure networking tunnel, and doesn’t have built-in features for event handling or user data export.