Ongoing monitoring ensures HVCI remains active and alerts you to any security policy violations or compatibility issues that emerge after deployment.
Set up automated monitoring using Microsoft Defender for Endpoint or Azure Monitor. Create a custom detection rule for HVCI status:
// KQL query for HVCI monitoring in Microsoft Defender
DeviceInfo
| where Timestamp > ago(1d)
| extend HVCIStatus = iff(isnotempty(OSArchitecture) and OSArchitecture contains "x64",
iff(DeviceGuardSecurityServicesRunning has "2", "Enabled", "Disabled"), "N/A")
| where HVCIStatus == "Disabled"
| project Timestamp, DeviceName, OSVersion, HVCIStatus
| summarize DisabledDevices = dcount(DeviceName) by bin(Timestamp, 1h)
For environments without Defender for Endpoint, create a PowerShell monitoring script:
# HVCI monitoring script for scheduled execution
$logPath = "C:\Logs\HVCI-Monitor.log"
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
try {
$deviceGuard = Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard
$hvciStatus = $deviceGuard.SecurityServicesRunning
if ($hvciStatus -contains 2) {
$status = "ENABLED"
} else {
$status = "DISABLED"
# Send alert email or write to event log
Write-EventLog -LogName Application -Source "HVCI Monitor" -EventId 1001 -EntryType Warning -Message "HVCI is disabled on $env:COMPUTERNAME"
}
"$timestamp - $env:COMPUTERNAME - HVCI Status: $status" | Out-File -FilePath $logPath -Append
}
catch {
"$timestamp - $env:COMPUTERNAME - HVCI Check Failed: $($_.Exception.Message)" | Out-File -FilePath $logPath -Append
}
Deploy this script via Intune as a PowerShell script or scheduled task. Configure it to run daily and alert on HVCI failures.
Set up compliance policies to enforce HVCI status:
- Navigate to Devices > Compliance policies > Create policy
- Select Windows 10 and later platform
- Under System Security, configure custom compliance rules
Pro tip: Use Azure Log Analytics to centralize HVCI monitoring logs from all devices for trend analysis and reporting.
Verification: Test the monitoring by temporarily disabling HVCI on a test device and confirming alerts are generated within the expected timeframe.