Skip to content

Instantly share code, notes, and snippets.

@leeramsay
Last active June 1, 2022 17:07
Show Gist options
  • Save leeramsay/a60a50d0ae6d1d48696e371350df06a3 to your computer and use it in GitHub Desktop.
Save leeramsay/a60a50d0ae6d1d48696e371350df06a3 to your computer and use it in GitHub Desktop.
gather AD site name on macOS, tested on 10.11 & 10.12

Saving this so I don't lose it. Quick and dirty check for AD site name.

Tested on 10.11 and 10.12

#!/bin/bash
[ $EUID -ne 0 ] && { echo "$0 must be run as root"; exit 1; }
AD_Forest=$(dscl localhost -list "/Active Directory")
AD_SiteName=$(/usr/libexec/PlistBuddy -c "print ActiveDirectory:sitename" "/Library/Preferences/OpenDirectory/DynamicData/Active Directory/${AD_Forest}.plist")
echo ${AD_SiteName}
@greggjaskiewicz
Copy link

sadly this way is not supported in BigSur

@WardsParadox
Copy link

Working in Monterey, 12.5 beta2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment