Error Details
| Fact | Value | Source | Note |
|---|---|---|---|
| Exact error string | ERROR_ALREADY_EXISTS: Cannot create a file when that file already exists | Event Viewer > Applications and Services Logs > Microsoft > Windows > SENSE > Operational (Event ID 5, 15, 28) | |
| Affected OS build range | Windows 11 23H2 | ||
| Registry key involved | HKLM:\SYSTEM\CurrentControlSet\Services\Sense | Registry Editor | |
| Relevant service/endpoint URL | https://endpoints.microsoft.com/ | ||
| Log line signature | Event ID 5, 15, 28 in SENSE Operational log | C:\Windows\System32\winevt\Logs\Microsoft-Windows-SENSE%4Operational.evtx |
Log Files to Check
C:\Windows\System32\winevt\Logs\Microsoft-Windows-SENSE%4Operational.evtxC:\Windows\Temp\mde_onboarding_*.log
What This Error Actually Means
The error code 0x800700B7, which translates to "ERROR_ALREADY_EXISTS: Cannot create a file when that file already exists," is raised by Microsoft Defender for Endpoint (MDE) during the onboarding process. This issue occurs when MDE attempts to create registry keys or service entries but finds them already in place from either a previous partial installation attempt or due to conflicting security products. The error manifests as an inability to proceed with the onboarding because critical components cannot be uniquely created, leading to a failure in establishing proper communication and functionality between the endpoint and Microsoft's backend services.Affected Versions and Scope
This specific issue is observed exclusively within Windows 11 build 23H2. It does not affect earlier versions of Windows or other builds of Windows 11. The error is particularly relevant for organizations that are rolling out MDE onboarding as part of their security strategy, especially those transitioning from older EDR solutions to Microsoft's offering. This problem does not occur in environments where the initial installation was successful without any interruptions or where no conflicting products were present.Where To Look First: Logs and Event IDs
To diagnose this issue effectively, sysadmins should first consult the following logs:C:\Windows\System32\winevt\Logs\Microsoft-Windows-SENSE%4Operational.evtxC:\Windows\Temp\mde_onboarding_*.log
Microsoft-Windows-SENSE/Operational log. These logs will provide detailed information about the onboarding process and any errors encountered during it.
Root Causes
The primary causes of this error can be categorized into a few distinct scenarios:Prior Onboarding Inconsistencies
This occurs when an earlier attempt to onboard MDE was interrupted, leaving certain registry keys or service entries in an inconsistent state. To identify this cause, check theHKLM:\SOFTWARE\Microsoft\Windows Advanced Threat Protection for the OrgId registry value; if it matches a different tenant ID, it indicates that the device was previously onboarded to another environment.
Conflicting Security Products
Another common reason is the presence of other Endpoint Detection and Response (EDR) solutions such as CrowdStrike Falcon, Carbon Black, or SentinelOne. These products may create conflicting service entries in the system registry, preventing MDE from onboarding properly. To diagnose this issue, runGet-WmiObject -Class Win32_Product | Where-Object Name -match 'CrowdStrike|Carbon|Sentinel|ESET|Sophos|Symantec'.
Incomplete Removal of Previous EDR Agents
If a previous EDR agent was not fully removed before attempting to onboard MDE, remnants may still exist in the system registry or as services. This can be identified by checking for existing service entries related to these agents and verifying their removal.Fix Procedure
To resolve this issue, follow these steps:Off-board the device from MDE: Navigate to
https://security.microsoft.com/, go to Settings > Endpoints > Device management > Offboarding. Download and run the offboarding package for Windows 10/11 as an administrator.Re-onboard the device after off-boarding is complete: Use the same portal path to download and execute the onboarding script.
If the above steps do not resolve the issue, manually remove the Sense service:
- Stop the service using
Stop-Service -Name Sense -Force. - Remove the registry key for the sense service:
Remove-Item HKLM:\SYSTEM\CurrentControlSet\Services\Sense -Recurse -Force. Before proceeding, back up this registry entry by runningreg export HKLM\SYSTEM\CurrentControlSet\Services\Sense C:\Sense_backup.reg. - After removal, re-run the onboarding script.
- Stop the service using
If a conflicting EDR agent exists, uninstall it first. For CrowdStrike Falcon, use the CS Removal Tool (csclient.exe /uninstall) to remove it.
- Be cautious when removing security components from managed devices as this can disrupt device enrollment and management.
For Intune-managed devices, utilize the MDE Security Settings Management policy in
https://security.microsoft.com/. Navigate to Settings > Endpoints > Security settings management. This feature allows for re-onboarding without local script execution.- To disable tamper protection on Intune-managed devices, navigate to Endpoint security > Antivirus > Windows Security Experience and set Tamper Protection to Off in the Intune admin center.
Error Code Variants
| Code | Description |
|---|---|
| 0x800705B4 | ERROR_SERVICE_REQUEST_TIMEOUT: The service did not respond to the start or control request in a timely fashion. |
| 0x800706BA | ERROR_NO_SYSTEM_RESOURCES: Insufficient system resources exist to complete the requested service. |
| 0x80072EFD | ERROR_INVALID_STATE: The operation failed because the object's state is invalid for this operation. |
Verification
To verify that the issue has been resolved, check the following:- The
Microsoft-Windows-SENSE/Operationallog should no longer contain Event IDs 5, 15, or 28 indicating an error. - In the Intune admin center, ensure that the device's status reflects successful onboarding and proper configuration under Settings > Endpoints > Device management.
- The
C:\Windows\Tempdirectory should no longer contain any MDE onboarding log files with errors.
Prevention
To prevent recurrence of this issue, ensure that:- All previous EDR agents are completely uninstalled before attempting to onboard new security solutions.
- The organization maintains a consistent and documented process for off-boarding and on-boarding MDE across all devices.
- Intune policies enforce strict removal procedures for conflicting security products through OMA-URI settings like
./Device/Vendor/MSFT/SecurityAgent/DisableConflictingApps. - Tamper protection is disabled in the Intune admin center before any changes to security components are made.