Skip to content

Instantly share code, notes, and snippets.

@smashism
Last active October 21, 2025 19:05
Show Gist options
  • Select an option

  • Save smashism/ef6f8ba7009038b4f5a031f25449225f to your computer and use it in GitHub Desktop.

Select an option

Save smashism/ef6f8ba7009038b4f5a031f25449225f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Extension attribute to see if a local user account is mdm enabled.
# Based on https://derflounder.wordpress.com/2025/04/04/identifying-mdm-managed-user-accounts-on-macos-sequoia/, thanks Rich.
# ekw 2025-10-16
# Get the GUID of the managed local user account
MDMManagedUserGUID=$(/usr/sbin/system_profiler SPConfigurationProfileDataType | grep "Managed User" | sed -E 's/.* ([0-9A-F-]{36}) .*/\1/')
# Find the username of the mdm enabled user account based on GUID
MDMManagedUserUsername=$(/usr/bin/dscl . -search /Users GeneratedUID "$MDMManagedUserGUID" | awk '{print $1}' | head -n 1 2>/dev/null)
/bin/echo "<result>$MDMManagedUserUsername</result>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment