diff --git a/server/service/osquery_utils/queries.go b/server/service/osquery_utils/queries.go index 60536f63a7..3baf7bb09c 100644 --- a/server/service/osquery_utils/queries.go +++ b/server/service/osquery_utils/queries.go @@ -1565,7 +1565,11 @@ func deduceMDMNameWindows(data map[string]string) string { } func directIngestMDMWindows(ctx context.Context, logger log.Logger, host *fleet.Host, ds fleet.Datastore, rows []map[string]string) error { - if len(rows) != 1 { + if len(rows) == 0 { + // no mdm information in the registry + return ds.SetOrUpdateMDMData(ctx, host.ID, false, false, "", false, "", "") + } + if len(rows) > 1 { logger.Log("component", "service", "method", "directIngestMDMWindows", "warn", fmt.Sprintf("mdm expected single result got %d", len(rows))) // assume the extension is not there diff --git a/server/service/osquery_utils/queries_test.go b/server/service/osquery_utils/queries_test.go index 4ea1704902..66121f87ff 100644 --- a/server/service/osquery_utils/queries_test.go +++ b/server/service/osquery_utils/queries_test.go @@ -715,6 +715,14 @@ func TestDirectIngestMDMWindows(t *testing.T) { wantIsServer: false, wantServerURL: "", }, + { + name: "off no rows", + data: []map[string]string{}, + wantEnrolled: false, + wantInstalledFromDep: false, + wantIsServer: false, + wantServerURL: "", + }, { name: "on automatic", data: []map[string]string{