Audit B2B Guest Devices Trust Type
Query
//Shouthout johannesblog.com for the idea
SigninLogs
//| where AppDisplayName =~ "Microsoft Teams"
| extend TrustType = tostring(DeviceDetail.trustType)
| where CrossTenantAccessType == @"b2bCollaboration"
| where AADTenantId != HomeTenantId //exclude B2b outbound
| where UserType == "Guest"
| project TimeGenerated, UserPrincipalName, AppDisplayName, IPAddress, TrustType,
DeviceId = tostring(DeviceDetail.deviceId),
DeviceName = tostring(DeviceDetail.displayName),
OperatingSystem = tostring(DeviceDetail.operatingSystem),
Browser = tostring(DeviceDetail.browser),
ConditionalAccessStatus, ResultType, ResultDescription
| order by TimeGenerated descExplanation
This KQL (Kusto Query Language) query is designed to analyze sign-in logs, specifically focusing on guest users accessing resources through cross-tenant collaboration. Here's a simplified breakdown of what the query does:
-
Data Source: It starts by querying the
SigninLogstable, which contains records of user sign-ins. -
Extend TrustType: It creates a new column called
TrustTypeby converting thetrustTypefield from theDeviceDetailobject into a string. -
Filter for Cross-Tenant Collaboration: It filters the logs to include only those sign-ins that are part of "b2bCollaboration" (business-to-business collaboration).
-
Exclude B2B Outbound: It excludes records where the
AADTenantId(Azure Active Directory Tenant ID) is the same as theHomeTenantId, focusing on inbound guest access rather than outbound. -
Filter for Guest Users: It further filters the logs to include only those sign-ins where the
UserTypeis "Guest". -
Select Specific Columns: It selects specific columns to display in the results, including:
TimeGenerated: The timestamp of the sign-in event.UserPrincipalName: The user's principal name (often their email).AppDisplayName: The name of the application accessed.IPAddress: The IP address from which the sign-in occurred.TrustType: The trust type of the device.DeviceId: The ID of the device used for sign-in.DeviceName: The name of the device.OperatingSystem: The operating system of the device.Browser: The browser used for sign-in.ConditionalAccessStatus: The status of any conditional access policies applied.ResultType: The result type of the sign-in attempt.ResultDescription: A description of the sign-in result.
-
Order by Time: Finally, it orders the results by the
TimeGeneratedcolumn in descending order, showing the most recent sign-ins first.
Overall, this query is useful for monitoring and analyzing guest user sign-ins from other tenants, focusing on cross-tenant collaboration scenarios.
Details

Jay Kerai
Released: May 1, 2026
Tables
Keywords
Operators