Windows Hello for Business is one of the best security improvements you can deploy across your estate — but it breaks silently, in ways that are genuinely hard to diagnose. A user opens their laptop, taps their PIN, and gets a generic "Something went wrong" screen. They call the helpdesk. The helpdesk resets the PIN. It works. Until it doesn't again, two weeks later, on a different device. This post shows you how to stop that cycle by deploying an Intune Proactive Remediation pair that detects WHfB problems and repairs what a script can safely repair, before the user ever notices.
Both scripts are free and open source. Download them from the Imran76Awan/WHFB repository on GitHub — no sign-in required.
WHfB breaks silently — PRT expires, NGC keys corrupt, services stop. Here is a Proactive Remediation pair that detects all six failure modes, repairs the ones a script can safely repair, and stops when it cannot, including the trick for running user-context commands from SYSTEM.
What actually breaks in Windows Hello for Business
WHfB has four moving parts that all need to be healthy at the same time. When any one of them drifts, authentication fails:
The Windows Hello key stored in C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Ngc\. Tied to the user and device. If it gets corrupted or the folder permissions break, WHfB cannot function.
The Primary Refresh Token is what gives users seamless SSO to Azure AD resources. WHfB relies on a valid PRT. If the PRT expires or the WAM token broker loses its session, sign-in fails even if the NGC key itself is healthy.
Four Windows services underpin the stack: KeyIso (CNG Key Isolation), NgcSvc, NgcCtnrSvc, and TokenBroker (Web Account Manager). Any of them in Stopped state = broken authentication.
TPM 2.0 must be present, enabled, and ready. WHfB policy must not be explicitly disabled in the registry. BIOS updates can reset TPM ownership. GPO conflicts can set Enabled=0 and silently block provisioning.
How to verify — run dsregcmd /status
Before you deploy anything, run this on an affected device and look at these specific fields. This is the exact output the detection script parses.
A broken device shows AzureAdPrt : NO or NgcSet : NO. That is your trigger to remediate.
What broken WHfB looks like in Event Viewer
Before deploying the detection script, you can confirm the failure by looking at two event logs. Open Event Viewer and navigate to Applications and Services Logs → Microsoft → Windows → User Device Registration → Admin. A device with a missing PRT shows Event ID 104:
For NGC key failures, check Applications and Services Logs → Microsoft → Windows → HelloForBusiness → Operational. Event ID 302 tells you WHfB provisioning was attempted and failed:
dsregcmd /status is more reliable than Event Viewer for confirming the broken state.
The Detection Script — Detect-WHfB.ps1
The detection script runs 6 checks. It exits 0 (compliant, no action) or 1 (non-compliant, trigger remediation). It can run as SYSTEM or as the logged-on user — PRT and NGC checks are only valid in user context: as SYSTEM the script now skips those two checks and says so, instead of reporting healthy devices as broken. When the PRT is missing it also reads the PRT diagnostics and classifies the cause.
The script uses a simple dsregcmd /status parser that converts each Key : Value line into a hashtable — no external module required, works on every Windows 10/11 device:
For the policy check, the script checks three different registry locations because different versions of Windows and different GPO/MDM paths write to different keys:
The Remediation Script — Remediate-WHfB.ps1
dsregcmd /cleanupaccounts and triggered UserTask-Roam. That folder is shared by every user on the device, so it removed every enrolled user's Hello credential, and no Microsoft page documents it as a repair. It is gone: step 5 now only reports the Hello key state, and the dsregcmd /forcerecovery fallback is gone too. AzureAdPrt and NgcSet are now read in the user's context, because Microsoft says the command “must run in a user context to retrieve a valid status”; read as SYSTEM, healthy devices looked broken. And before any PRT refresh, the remediation reads the PRT diagnostics: an AADSTS answer such as AADSTS130004 (“The user principal doesn't have the NGC ID key configured”) means Entra ID refused the request, so it stops and exits 1 instead of retrying every schedule. See when the Hello key is missing in Entra and which Hello and PRT fixes are safe to automate. The diagnostics parser has 22 tests, including Microsoft's own sample output. The user-context scheduled-task steps are parse-checked but I have not run them on a live device yet, so pilot first.The remediation script runs as SYSTEM (the default Intune context) and works through five steps in order. It logs everything to C:\ProgramData\WHfB-Repair\WHfB-Remediate_{computername}_{timestamp}.log. Step 5 only reports the Hello key state: the script never deletes a Hello credential.
The clever part: running user-context commands from SYSTEM
Here is the problem with PRT refresh: dsregcmd /refreshprt only works in user context — it reaches the WAM token broker, which is session-bound. But Intune remediations run as SYSTEM. If you call dsregcmd /refreshprt from SYSTEM it silently does nothing.
The solution is Invoke-AsLoggedOnUser — a function that registers a one-time scheduled task under the logged-on user's principal, fires it 3 seconds later, waits 15 seconds, then cleans it up:
LogonType Interactive with the logged-on user as principal. Windows Task Scheduler injects it into the user's active session, giving it access to the WAM token broker that handles Azure AD authentication. The task fires in user context even though the script registering it is running as SYSTEM. This is the same pattern used by SCCM/ConfigMgr for user-context deployments.
Live remediation output (earlier version)
This is the output of the version published in July 2026, before the 5 November changes. It is a real run on a device with a broken PRT and no NGC key, and its step 5 is the old NGC cleanup, which the current script no longer runs. I have not re-run the current version on a live device, so I have not replaced this output. Pre-remediation state: AzureAdPrt=NO, NgcSet=NO. Post-remediation: both restored without a reboot.
Clear-Tpm will invalidate your BitLocker protectors on every encrypted drive on the device. If you do not have the BitLocker recovery key saved in Entra ID or AD before you clear it, the drive becomes unrecoverable. The remediation script deliberately never touches the TPM. If TPM health is the actual failure, it needs a BIOS-level fix — not a script.
Deploy to Intune — step by step
- Name: WHfB Health Monitor
- Detection script: Upload
Detect-WHfB.ps1— Run with 64-bit PowerShell: Yes - Remediation script: Upload
Remediate-WHfB.ps1— Run with 64-bit PowerShell: Yes. Run this script using the logged-on credentials: No (SYSTEM) for this package - Schedule: Every 1 hour (or Daily — detection is lightweight)
- Scope: Assign to your All Windows Hello for Business users group
Detect-WHfB.ps1 only and the logged-on-credentials setting on Yes.
Reading the logs after remediation
Every remediation run writes a timestamped log to C:\ProgramData\WHfB-Repair\. Open it from a remote session or collect it via Intune device diagnostics. The format is easy to scan — look for [FAIL] or [WARN] entries first, then check whether the Post-Remediation State section shows PRT and NGC as YES.
I'll deploy and tune a Proactive Remediation pair like this one for your environment — tailored to your specific failure patterns, not just the six checks covered here.
Microsoft documentation references
- Windows Hello for Business overview — Microsoft Learn
- Troubleshoot Windows Hello for Business — Microsoft Learn
- Remediations (Proactive Remediations) in Microsoft Intune — Microsoft Learn
- Troubleshoot devices using dsregcmd — Microsoft Entra
- Windows Hello for Business event reference — Microsoft Learn
Detect-WHfB.ps1 and Remediate-WHfB.ps1 are part of the open-source EndpointIQ toolkit on GitHub. The remediation covers every common WHfB failure mode — PRT expiry, NGC corruption, stopped services, failed hybrid join — without touching the TPM or BitLocker. Safe to deploy broadly, not just to devices you already know are broken.