Added TPM Info to Device Details

This commit is contained in:
Oliver Kieselbach
2026-03-04 17:51:39 +01:00
parent b37e95c86b
commit bc264a69e3
4 changed files with 57 additions and 3 deletions
@@ -50,6 +50,7 @@ namespace AutopilotMonitor.Agent.Core.Monitoring.Collectors
var profileResult = CollectAutopilotProfile();
CollectSecureBootStatus();
CollectBitLockerStatus();
CollectTpmStatus();
CollectAadJoinStatus();
return profileResult;
@@ -491,6 +492,50 @@ namespace AutopilotMonitor.Agent.Core.Monitoring.Collectors
}
}
private void CollectTpmStatus()
{
try
{
var data = new Dictionary<string, object>();
using (var searcher = new ManagementObjectSearcher(
new ManagementScope(@"\\.\root\CIMV2\Security\MicrosoftTpm"),
new ObjectQuery("SELECT IsActivated_InitialValue, IsEnabled_InitialValue, IsOwned_InitialValue, ManufacturerIdTxt, ManufacturerVersion, SpecVersion FROM Win32_Tpm")))
{
foreach (ManagementObject obj in searcher.Get())
{
data["isActivated"] = obj["IsActivated_InitialValue"]?.ToString() == "True";
data["isEnabled"] = obj["IsEnabled_InitialValue"]?.ToString() == "True";
data["isOwned"] = obj["IsOwned_InitialValue"]?.ToString() == "True";
data["manufacturerName"] = obj["ManufacturerIdTxt"]?.ToString();
data["manufacturerVersion"] = obj["ManufacturerVersion"]?.ToString();
// SpecVersion is comma-separated: "2.0, 0, 1.59" → first element is the spec version
var specVersion = obj["SpecVersion"]?.ToString();
if (!string.IsNullOrEmpty(specVersion))
{
var parts = specVersion.Split(',');
data["specVersion"] = parts[0].Trim();
}
}
}
if (data.Count > 0)
{
EmitDeviceInfoEvent("tpm_status", $"TPM: {data["manufacturerName"]} v{data["manufacturerVersion"]}", data);
}
else
{
data["available"] = false;
EmitDeviceInfoEvent("tpm_status", "TPM: not available", data);
}
}
catch (Exception ex)
{
_logger.Warning($"EnrollmentTracker: failed to collect TPM status: {ex.Message}");
}
}
private void CollectAadJoinStatus()
{
try
@@ -1 +1 @@
210
211
@@ -1130,6 +1130,7 @@ function DeviceDetailsCard({ events }: { events: EnrollmentEvent[] }) {
const imeVersion = getEventData("ime_agent_version");
const bitLockerStatus = getEventData("bitlocker_status");
const secureBootStatus = getEventData("secureboot_status");
const tpmStatus = getEventData("tpm_status");
const deviceLocation = getEventData("device_location");
// Check if we have any device detail events at all
@@ -1298,11 +1299,19 @@ function DeviceDetailsCard({ events }: { events: EnrollmentEvent[] }) {
)}
{/* Security */}
{(bitLockerStatus || secureBootStatus) && (
{(bitLockerStatus || secureBootStatus || tpmStatus) && (
<DetailSection title="Security">
{secureBootStatus && (
<DetailRow label="SecureBoot" value={secureBootStatus.uefiSecureBootEnabled ? "Enabled" : "Disabled"} />
)}
{tpmStatus && (
<>
<DetailRow label="TPM" value={tpmStatus.available === false ? "Not Available" : `${tpmStatus.manufacturerName ?? "Unknown"} (${tpmStatus.manufacturerVersion ?? "?"})`} />
{tpmStatus.specVersion && (
<DetailRow label="TPM Spec Version" value={tpmStatus.specVersion} />
)}
</>
)}
{bitLockerStatus && (
<>
<DetailRow label="BitLocker" value={bitLockerStatus.systemDriveProtected ? "Protected" : "Not Protected"} />
File diff suppressed because one or more lines are too long