|
| 1 | +# Palo Alto GlobalProtect Policy Enforcer |
| 2 | + |
| 3 | +In generally, Mobile Device Management systems like Microsoft Intune [support the distribution of standardized plist files to managed users](https://learn.microsoft.com/en-us/intune/intune-service/configuration/preference-file-settings-macos). This makes it easy to distribute updated plist files to users when specific settings need to be changed, removed, or added. These plist files are typically deployed to the `/Library/Managed Preferences` location. |
| 4 | + |
| 5 | +Unfortunately, some applications, such as GlobalProtect for macOS, do not support reading plist files from this location. Instead, they read directly from `/Library/Preferences/com.paloaltonetworks.GlobalProtect.settings.plist`. These policy enforcer scripts are specifically developed for such applications that do not support reading deployed plist files from `/Library/Managed Preferences`. The goal is to provide an easy way to distribute configuration values to these applications — whether it's for deploying new settings, modifying existing ones, or removing deprecated entries. |
| 6 | + |
| 7 | +In this example, we provide a policy enforcer script for GlobalProtect on macOS. |
| 8 | + |
| 9 | +## Palo Alto GlobalProtect Policy Enforcer (Machine Level) |
| 10 | + |
| 11 | +> [!NOTE] |
| 12 | +> This script can be deployed as a separate script deployment or with a post-install script during GlobalProtect installation via Intune. We recommend using both options to ensure proper configuration. |
| 13 | +
|
| 14 | +This custom script is designed to **automate the configuration of GlobalProtect VPN policies** on macOS devices. It is especially useful in **MDM deployment scenarios** such as Microsoft Intune, where consistent and secure configuration across devices is critical. |
| 15 | + |
| 16 | +### Purpose |
| 17 | + |
| 18 | +This script ensures that key GlobalProtect settings are **created, updated, or removed** at the machine level using `PlistBuddy`. It helps enforce security, compliance, and user experience standards by: |
| 19 | + |
| 20 | +- Disabling unnecessary or insecure features. |
| 21 | +- Enabling enterprise-grade protections. |
| 22 | +- Pre-configuring baseline settings of GlobalProtect to corporate environment. |
| 23 | +- Preventing users from changing critical settings. If user change those settings, they will be enforced back to defined values. |
| 24 | + |
| 25 | +### Benefits |
| 26 | + |
| 27 | +- ✅ Ensures **consistent policy enforcement** across all managed Macs |
| 28 | +- ✅ Reduces **manual configuration errors** |
| 29 | +- ✅ Supports **CIS/NIST-aligned hardening** |
| 30 | +- ✅ Fully **automated and silent** when deployed via Intune |
| 31 | +- ✅ Logs all actions for **auditability and troubleshooting** |
| 32 | + |
| 33 | +--- |
| 34 | +### What the Script Does |
| 35 | + |
| 36 | +The script uses `PlistBuddy` to: |
| 37 | + |
| 38 | +- **Create** missing `.plist` files and directories |
| 39 | +- **Add or update** specific keys and values |
| 40 | +- **Delete** obsolete or undesired keys (optional) |
| 41 | + |
| 42 | +#### Policies (`com.paloaltonetworks.GlobalProtect.settings.plist`) |
| 43 | + |
| 44 | +> [!NOTE] |
| 45 | +> - These are example settings and values. Modify as needed before deploying this script to managed devices. |
| 46 | +> - Please refer to [GlobalProtect Documentation](https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings#idd39ecf6d-6771-4ee3-a4d1-2ba5bbbad1bc) from Palo Alto Networks to validate which key/value pairs are supported and required. |
| 47 | +> - The script includes a commented-out example of how to delete values. |
| 48 | +> - This script enforces **machine-level** policies and does not target individual users. |
| 49 | +
|
| 50 | +| Key Path | Type | Value | Notes | |
| 51 | +|----------|------|-------|-------| |
| 52 | +| `Palo Alto Networks:GlobalProtect:PanSetup:Portal` | string | `vpn.example.com` | Set your GlobalProtect portal address. [More information](https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings/app-behavior-options). | |
| 53 | +| `Palo Alto Networks:GlobalProtect:PanSetup:Prelogon` | string | `1` | Enables pre-logon feature. [More information](https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings/app-behavior-options). | |
| 54 | +| `Palo Alto Networks:GlobalProtect:Settings:connect-method` | string | `pre-logon` | Connection method setting. [More information](https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings/app-behavior-options). | |
| 55 | +| `Palo Alto Networks:GlobalProtect:Settings:default-browser` | string | `no` | Prevents launching default browser. [More information](https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings/app-behavior-options). | |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### Customization |
| 60 | + |
| 61 | +To **modify or extend** the script: |
| 62 | + |
| 63 | +- To **add a new key or update existing key**, use the `enforce_value` function. |
| 64 | +- To **delete a key**, use the `delete_key` or function. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +### Script Settings |
| 69 | + |
| 70 | +| Setting | Value | |
| 71 | +|--------|-------| |
| 72 | +| Run script as signed-in user | ❌ No | |
| 73 | +| Hide script notifications on devices | ✅ Yes | |
| 74 | +| Script frequency | Every 1 day | |
| 75 | +| Number of times to retry if script fails | 3 | |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +### Log File |
| 80 | + |
| 81 | +The log file will output to ***/Library/Logs/Microsoft/IntuneScripts/PaloAltoGlobalProtectPolicyEnforcerMachineLevel/PaloAltoGlobalProtectPolicyEnforcerMachineLevel.log*** by default. Exit status is either 0 or 1. To gather this log with Intune remotely take a look at [Troubleshoot macOS shell script policies using log collection](https://docs.microsoft.com/en-us/mem/intune/apps/macos-shell-scripts#troubleshoot-macos-shell-script-policies-using-log-collection) |
| 82 | + |
| 83 | +``` |
| 84 | +############################################################## |
| 85 | +# Fri Jul 4 17:12:51 EEST 2025 | Starting running of script PaloAltoGlobalProtectPolicyEnforcerMachineLevel |
| 86 | +############################################################## |
| 87 | +
|
| 88 | +Fri Jul 4 17:12:51 EEST 2025 | Applying Palo Alto GlobalProtect policies... |
| 89 | +Fri Jul 4 17:12:51 EEST 2025 | Directory already exists: /Library/Preferences |
| 90 | +Fri Jul 4 17:12:51 EEST 2025 | [CREATE] Creating empty plist at /Library/Preferences/com.paloaltonetworks.GlobalProtect.settings.plist |
| 91 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Creating missing dictionary: Palo Alto Networks |
| 92 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Creating missing dictionary: Palo Alto Networks:GlobalProtect |
| 93 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Creating missing dictionary: Palo Alto Networks:GlobalProtect:PanSetup |
| 94 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Palo Alto Networks:GlobalProtect:PanSetup:Portal = vpn.example.com |
| 95 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Palo Alto Networks:GlobalProtect:PanSetup:Prelogon = 1 |
| 96 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Creating missing dictionary: Palo Alto Networks:GlobalProtect:Settings |
| 97 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Palo Alto Networks:GlobalProtect:Settings:connect-method = pre-logon |
| 98 | +Fri Jul 4 17:12:51 EEST 2025 | [ADD] Palo Alto Networks:GlobalProtect:Settings:default-browser = no |
| 99 | +
|
| 100 | +Fri Jul 4 17:12:51 EEST 2025 | Script PaloAltoGlobalProtectPolicyEnforcerMachineLevel completed. |
| 101 | +
|
| 102 | +############################################################## |
| 103 | +# Fri Jul 4 18:12:40 EEST 2025 | Starting running of script PaloAltoGlobalProtectPolicyEnforcerMachineLevel |
| 104 | +############################################################## |
| 105 | +
|
| 106 | +Fri Jul 4 18:12:40 EEST 2025 | Applying Palo Alto GlobalProtect policies... |
| 107 | +Fri Jul 4 18:12:40 EEST 2025 | Directory already exists: /Library/Preferences |
| 108 | +Fri Jul 4 18:12:40 EEST 2025 | [OK] Palo Alto Networks:GlobalProtect:PanSetup:Portal is already set to vpn.example.com |
| 109 | +Fri Jul 4 18:12:40 EEST 2025 | [UPDATE] Palo Alto Networks:GlobalProtect:PanSetup:Prelogon: 1 -> 0 |
| 110 | +Fri Jul 4 18:12:40 EEST 2025 | [OK] Palo Alto Networks:GlobalProtect:Settings:connect-method is already set to pre-logon |
| 111 | +Fri Jul 4 18:12:40 EEST 2025 | [OK] Palo Alto Networks:GlobalProtect:Settings:default-browser is already set to no |
| 112 | +
|
| 113 | +Fri Jul 4 18:12:40 EEST 2025 | Script PaloAltoGlobalProtectPolicyEnforcerMachineLevel completed. |
| 114 | +############################################################## |
| 115 | +``` |
0 commit comments