T The Triage ManualTechnical Guides for IT Emergencies
P4 · Endpoint & Device Management

Detect AAD/Hybrid/On-Prem AD Join Status via Registry When Running as SYSTEM

Scripts executing as NT AUTHORITY\SYSTEM cannot use dsregcmd /status to determine Azure AD join status because the utility requires a domain user account context, causing it to fail silently or with a recognition error in RMM environments. The reliable alternative is to query the HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo registry key directly, which is accessible to SYSTEM and exposes TenantId and UserEmail values for AAD-joined machines. Combining this with a Netlogon or DirectoryServices check allows complete classification of any endpoint as AAD joined, Hybrid joined, on-prem only, or unjoined.

Indicators

Likely causes

Diagnostic steps

  1. Confirm failure by running 'dsregcmd /status' as SYSTEM. Expected error: 'dsregcmd is not recognized as the name of a cmdlet, function, script file, or operable program.' This validates the context restriction rather than a PATH issue.
  2. Confirm the restriction is context-based by also trying the full path: '& "C:\Windows\System32\dsregcmd.exe" /status'. If this also fails, the execution context (SYSTEM) is confirmed as the cause.
  3. Query the AAD join registry key: '$subKey = Get-Item "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo" -ErrorAction SilentlyContinue'. If the key exists, the machine is AAD joined or Hybrid AD joined.
  4. Enumerate GUID sub-keys under JoinInfo and extract join details: '$guids = $subKey.GetSubKeyNames(); foreach ($guid in $guids) { $guidSubKey = $subKey.OpenSubKey($guid); $tenantId = $guidSubKey.GetValue("TenantId"); $userEmail = $guidSubKey.GetValue("UserEmail"); Write-Output "TenantId: $tenantId | UserEmail: $userEmail" }'
  5. Check for on-prem AD membership by querying the Netlogon registry key: '(Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" -ErrorAction SilentlyContinue).DomainName'. A non-null value indicates on-prem domain membership. Alternatively use: '[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()' wrapped in a try/catch.
  6. Combine results to classify the endpoint: (a) CloudDomainJoin key exists AND Netlogon DomainName is populated = Hybrid AD joined; (b) CloudDomainJoin key exists, no DomainName = AAD joined only; (c) No CloudDomainJoin key, DomainName populated = on-prem AD only; (d) Neither present = unjoined/workgroup.
  7. Output or store the classification result in the RMM platform custom field or device attribute for grouping, reporting, or policy targeting.

Resolution path

Prevention

Tools

References

azure-adaad-joinhybrid-ad-joinon-prem-addomain-join-detectionpowershellregistrydsregcmdsystem-accountnt-authority-systemrmmendpoint-managementactive-directoryworkgroupautomation