Prepare your Intune tenant
What to set up in Microsoft Intune and Microsoft Entra ID before you deploy DefenseClaw with the Intune pages - licences, automatic enrollment, the Apple push certificate, device groups, assigning the package and the Remediations - and how identity-based guardrail profiles work on Intune-managed devices. Includes a Graph helper with a preview mode.
This page covers what has to be true in the tenant before the Intune recipes work, and a helper that checks it and does the repeatable parts with Microsoft Graph. DefenseClaw never calls Intune or Graph; the helper is for you, the administrator.
Validation status
Run on a test tenant in the PR #1304 pass: licences, users and groups, automatic enrollment, the Apple push certificate, enrolled Windows 11, Ubuntu 24.04 Desktop and macOS devices, every helper command with throwaway objects, and delivery of DefenseClaw to all three OSes.
What to prepare
| Step | Windows | macOS | Linux |
|---|---|---|---|
| Licences | Intune, Entra ID P1 or P2, Windows Enterprise for Remediations | Intune | Intune |
| Admin center settings | MDM user scope, Windows Hello default | Apple push certificate | None |
| Enroll devices | Join to Entra ID | Company Portal | Intune app and Microsoft Edge on a desktop |
| Device groups | One group | One group | One group |
| Assign DefenseClaw | Win32 app, Remediations | Shell script | Platform script |
| Identity | Entra accounts | Local accounts | Local accounts |
1. Licences
- Intune for each user who enrolls a device.
- Entra ID P1 or P2, which Microsoft documents for automatic MDM enrollment.
- Windows Enterprise E3 or E5, Education A3 or A5, or Windows VDA for Remediations (Intune on Windows).
- A usage location on each user before you can assign a licence.
intune_tenant.py check reports which of these the tenant has.
2. Admin center settings that need a person
Set these as an Intune administrator. Microsoft Graph refuses an app-only token for the first two.
- MDM user scope. Devices > Windows > Enrollment > Automatic Enrollment: set Microsoft Intune MDM user scope to All, or Some and a group.
- Windows Hello for Business default. Decide it in Devices > Windows > Enrollment. Disabled stops new devices from asking for a PIN.
- Apple push certificate (macOS only). In Devices > macOS > Enrollment
Apple MDM Push certificate, download the signing request, create the certificate at
identity.apple.com/pushcert, and upload the.pem. It lasts a year; renew it with the same Apple ID or every Mac must enroll again.
3. Enroll devices
- Windows 10 or 11. Settings > Accounts > Access work or school > Join this device to Microsoft Entra ID. Intune cannot enroll Windows Server.
- Linux. On Ubuntu 24.04 Desktop (GNOME), install Microsoft Edge and the Intune
app from
packages.microsoft.com, then register the device. It needs the desktop session; accounts stay local. - macOS. Enroll with Company Portal after the push certificate exists, and approve the MDM profile in System Settings.
4. Device groups
Assign apps and scripts to one group per OS. Every helper command that changes the
tenant prints a plan until you add --apply.
python3 intune_tenant.py groups --name defenseclaw-windows --name defenseclaw-macos --name defenseclaw-linux
python3 intune_tenant.py groups --name defenseclaw-windows --name defenseclaw-macos --name defenseclaw-linux --apply
python3 intune_tenant.py groups --add-device PC-0042:defenseclaw-windows --apply[plan] group defenseclaw-windows: would create a static security group
[plan] group defenseclaw-macos: would create a static security group
[plan] group defenseclaw-linux: would create a static security group
Nothing was changed. Run again with --apply to make these changes.5. Assign the package and the health check
The helper does not upload packages: build and upload the Win32 app as
Intune on Windows describes. Then assign it and
add the Remediations package. Run these from packaging/mdm/intune/tenant:
python3 intune_tenant.py assign-app --app "DefenseClaw Enterprise" --group defenseclaw-windows --apply
python3 intune_tenant.py remediation --group defenseclaw-windows --daily-at 02:00 --apply
python3 intune_tenant.py macos-script --name "DefenseClaw Enterprise" --file ../../macos/defenseclaw-enterprise.sh --group defenseclaw-macos --applyassign-app assigns an uploaded app by its exact display name (intent required by
default). remove-assignment removes it. remediation creates the Remediations
package and a daily schedule. macos-script creates the macOS shell script; fill in
the wrapper's settings block first (Intune on macOS).
If the helper reports detection only: the tenant stored runRemediationScript=false,
enable remediation on the assignment in the admin center. The Linux platform script is
created in the admin center (Intune on Linux).
6. Check the result
python3 intune_tenant.py check --platform windows --group defenseclaw-windowscheck exits 1 when a check fails. A trimmed run against the test tenant:
INFO tenant Contoso
PASS MDM authority intune
PASS Intune licence found
PASS Entra ID P1 or P2 AAD_PREMIUM, AAD_PREMIUM_P2
PASS Windows Enterprise (Remediations) found
WARN MDM user scope cannot be read with this token (401 AccessDenied: Unsupported app-only call.). ...
PASS group defenseclaw-windows 1 member(s)devices --noncompliant and status --app ... --remediation ... read device and
install state. Credentials, Graph permissions and every command are in
The helper; failures are in Troubleshooting.
Identity through Intune
DefenseClaw reads the account on the device, so what it sees depends on how users
sign in, not on Intune. Guardrail profiles (guardrail.profiles,
profile_assignments) ship in the config you deliver and apply to the standalone
profile only.
| Device | Accounts | What DefenseClaw records | Groups for a profile |
|---|---|---|---|
| Windows, Entra-joined | Entra accounts | The same as any Entra-joined computer: directory entra_id, the SID, the UPN and the tenant (the Entra guide) | An Entra group only after a built-in local group lists it |
| Linux, enrolled with the Intune app | Local accounts. The Entra user is only the device's primary user | Directory local, source nss_files, verified assurance and no principal (observed live) | Local groups and accounts; no Entra groups. A root Intune script maintained a local group and its profile assignment matched live |
| macOS, enrolled with Company Portal | Local accounts; with Platform SSO, local accounts linked to Entra users | Directory local; with Platform SSO and standalone enterprise, entra_id and the UPN for a registered account (observed live) | macOS groups only: Platform SSO gives no Entra groups (observed live; Entra on macOS) |
For that Linux pattern, edit and upload packaging/mdm/intune/linux/sync-local-group.sh
as a separate root platform script. Its MEMBERS setting is the complete local group
membership list; the script refuses an existing group it did not create or a root
administrator did not explicitly claim (Linux setup).
Intune enrollment alone does not synchronize Entra group membership to Linux. Example
profiles, the Entra group mapping on Windows and a config-only change are in
Guardrail profiles and Entra groups below.
A device in bundle mode takes config changes only as signed bundles and refuses a
plain config with bundle_required.
Guardrail profiles and Entra groups
Put the profiles in the config.yaml you give the package builder (Windows), or in
the config block of the macOS and Linux wrapper. For an Entra-joined Windows fleet,
assign by user, or by group SID after the local group step below:
guardrail:
profiles:
strict: {mode: action, block_at: MEDIUM}
ml-team: {mode: observe}
profile_assignments:
- profile: ml-team
match:
groups: ["S-1-12-1-1864145422-1280850733-3047453086-4192786374"] # Entra group SID
default_profile: strict
ai_discovery:
include_user_principal: trueensure validates the file before it applies it. A config with an unknown profile
fails, on Linux and macOS with config_invalid and on standalone Windows with
invalid_arguments and exit 1639, and leaves the installed config in force
(Deliver it to managed hosts).
A complete starting point is admin-config.windows.example.yaml in
packaging/identity/entra.
Entra groups on Windows need one more thing from Intune: a policy that puts the
group into a built-in local group, with the group's SID. The recipe (an Account
protection policy, Local user group membership, the group Users, action
Add (Update)) is in
Entra groups on Windows;
delivering it through Intune has not been tested. On a single computer,
Add-EntraGroupToLocalGroup.ps1 in packaging/identity/entra makes the same
membership with the same Windows API. After the mapping and the user's Entra
membership are in place, sign out and back in. If the new token still lacks the
SID, run dsregcmd /refreshprt in the user's session, wait for the refresh, then
sign out and back in again; in two live checks a plain sign-in alone still lacked
the SID. Live hook decisions can then wait up to 15 minutes for the gateway's
directory cache.
A config-only change on Windows needs a new package and a detection script that
checks the config hash; see
Change the config, upgrade and roll back.
A device in bundle mode refuses that package with bundle_required; deliver a new
signed bundle instead.
The helper
The helper is
packaging/mdm/intune/tenant/intune_tenant.py,
one file that needs only Python 3 and no packages.
python3 intune_tenant.py --helpIt reads credentials from the environment, never from arguments:
AZURE_TENANT_ID,AZURE_CLIENT_IDandAZURE_CLIENT_SECRETfor an app registration with these application permissions, admin-consented:Organization.Read.All,Group.ReadWrite.All,Device.Read.All,DeviceManagementServiceConfig.Read.All,DeviceManagementManagedDevices.Read.All,DeviceManagementApps.ReadWrite.AllandDeviceManagementScripts.ReadWrite.All. Use read-only versions of the last two to only check and report.- Or
GRAPH_ACCESS_TOKEN, a token with the same delegated permissions. A token fromaz account get-access-token --resource-type ms-graphworks for the directory calls; the Intune calls need an app registration with the Intune permissions.
| Command | Changes the tenant |
|---|---|
check, devices, status | No |
groups, assign-app, remove-assignment, remediation, macos-script | With --apply only |
The helper uses the beta Graph endpoint for Intune, which Microsoft can change.
When a call fails, it prints Graph's error and exits 1.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
check warns 401 AccessDenied: Unsupported app-only call for the MDM user scope | Expected with an app-only token. Read the setting in the admin center |
Writing enrollment defaults returns 403 Tenant is not Global Admin or Intune Service Admin | Graph refuses app-only writes to them. Use the admin center as an Intune administrator |
| A joined Windows computer is not in Intune | The MDM user scope is None, or the user has no Intune licence |
| Remediations are missing or do not run | The tenant lacks a Windows Enterprise licence, or the device has not signed in since it was assigned one |
assign-app says there is no app with that name | Upload the app first. The name must match the display name exactly |
check fails the Apple push certificate | Upload it (step 2). macOS enrollment needs it |
Install with an MDM
The contract every MDM recipe follows to deliver, run, detect, upgrade, reconfigure and remove the standalone DefenseClaw enterprise deployment on Windows, Linux and macOS.
Intune on Windows
Deploy the standalone DefenseClaw enterprise profile to Windows x64 with a Microsoft Intune Win32 app, keep it healthy with Remediations, deliver the AI Defense key, change the config and remove it.