Audit weekend and off-hours sign-in activity in Microsoft Entra ID to surface compromise indicators and triage suspicious accounts.
Complexity: Intermediate. Impact: security + identity-protection + audit + incident-response + entra-id.
Why use this workflow
Attackers frequently target accounts during off-hours, such as weekends, holidays, and overnight windows, when IT staff are less likely to respond quickly. Microsoft Entra ID Identity Protection and the sign-in audit logs together give you a detailed picture of every authentication attempt: where it came from, what device was used, whether it succeeded, and whether the Microsoft risk engine scored it as anomalous.
A periodic review of risky sign-ins lets you catch three high-value patterns:
- Impossible travel: the same account authenticating from two geographically distant locations in a short time window, which usually indicates credential theft.
- Unfamiliar locations: sign-ins from countries or networks the user has never used before, often the first visible sign of a compromised password.
- Repeated failures: bursts of failed attempts that may indicate password spraying, brute force, or MFA fatigue attacks.
When to run it
- Every Monday morning to cover the prior weekend.
- The morning after any extended holiday.
- Ad hoc when a user, manager, or help desk reports a suspicious email, device prompt, or login alert.
- As part of quarterly security reviews for privileged accounts.
Expected outcomes
- A complete inventory of risky sign-ins and risk detections for the selected time window.
- A per-user breakdown of failures, locations, IP addresses, and devices used.
- A verdict for each flagged user (low, medium, or high risk), with the reasoning documented.
- Remediation actions taken (revoked sessions, disabled accounts, forced password resets) where warranted.
- A record suitable for compliance and audit trails.
Risks and considerations
- Do not disable accounts reflexively. Multiple cities within a single country, or several IPs over a weekend, are often ISP or mobile carrier routing rather than compromise. Investigate before you contain.
- Error code 65001 is not a credential attack. It means admin consent has not been granted for an application. Do not treat it as a brute-force indicator.
- Aggregated location data can mislead. If a tool groups sign-ins by "all locations seen," a user who signed in from one country last month and another this weekend may look like impossible travel. Always drill into the chronological timeline before you conclude.
- Privileged accounts deserve extra scrutiny. Treat any anomaly on a Global Administrator, Privileged Role Administrator, or Exchange Administrator account as high severity even if the evidence is thin.
- Preserve evidence before remediating. Export the sign-in log rows and risk detections to immutable storage before you revoke sessions or reset passwords. You may need them for a formal investigation.
- Identity Protection requires Entra ID P2. Without it, the
riskyUsersandriskDetectionsendpoints return limited or no data and you must rely on the raw sign-in logs.
Required permissions
| Permission | Why it's needed |
|---|---|
| AuditLog.Read.All | Read the Entra ID sign-in audit logs to retrieve success and failure events, locations, IPs, and device details. |
| IdentityRiskyUser.Read.All | Query currently risky users and their risk state (atRisk, confirmedCompromised, remediated). |
| IdentityRiskEvent.Read.All | Read Identity Protection risk detections (impossible travel, unfamiliar sign-in, leaked credentials, and so on). |
| User.ReadWrite.All | Required if you act on findings: disable accounts or update user properties. |
| Directory.Read.All | Resolve user IDs to UPNs and display names, and read directory role memberships for privileged-account context. |
| User.RevokeSessions.All | Revoke active refresh tokens for compromised or suspicious accounts through /revokeSignInSessions. |
Ask Dex
Paste the prompt into a Dex conversation.
Prompt for IT admins
Review risky sign-ins from the past weekend (or the window {start_date} to {end_date}). Surface impossible travel, unfamiliar locations, and repeated failures. For each flagged user, give me a verdict (benign / investigate / contain) with evidence, and propose remediation actions where warranted.
Manual steps (admin center)
Step 1: Open Identity Protection
- Go to the Microsoft Entra admin center > Protection > Identity Protection.
- On the overview page, note the totals for Risky users, Risky sign-ins, and Risk detections.
Step 2: Review risky sign-ins
- Open Identity Protection > Report > Risky sign-ins.
- Set the Date filter to cover the window you want to audit (for example, the last weekend, or "Last 7 days").
- Optionally filter by Risk level (High, Medium, Low) and Risk state (At risk, Confirmed compromised).
- Select each sign-in to inspect the Basic info, Location, Device info, and Risk info tabs. Pay particular attention to the Risk event types column. Values like
unfamiliarFeatures,atypicalTravel, ormaliciousIPAddressare the highest-signal indicators.
Step 3: Review risk detections
- Open Identity Protection > Report > Risk detections.
- Use the same date range. This view shows why a sign-in was risky, even when it was allowed through.
- Sort by Risk level descending and walk through any High or Medium entries.
Step 4: Cross-check against sign-in logs
- Go to Identity > Monitoring & health > Sign-in logs.
- Apply the filter
Status = Failureand your target date range. - Group by user (use the User column filter) and look for users with repeated failures, or failures that span several countries within a few hours.
- Open any suspicious row to see the Authentication Details, Conditional Access, and Additional Details tabs.
Step 5: Triage each flagged user
- For each user who appears suspicious, build a timeline: sort their sign-ins by Date ascending and look for city or country changes within an unrealistically short interval.
- Check the IP address and Autonomous system fields. Residential IPs from the user's home country are usually benign. Hosting-provider or VPN ASNs on a historically on-site user are worth investigating.
- Confirm the failure reason codes.
50126= bad password,50053= account locked,50055= password expired,530003= device not compliant,65001= app consent missing (not a credential attack).
Step 6: Take action
- For confirmed compromise: open the user's profile, select Revoke sessions, then Reset password, and mark the user Confirm compromised in Identity Protection.
- For suspicious but unconfirmed activity: contact the user out-of-band (by phone, not email), verify their activity, and mark the user Confirm safe or Dismiss user risk once cleared.
- Document the review in your ticketing or SIEM system with the evidence (risk detection IDs and sign-in correlation IDs).
Microsoft Graph API
Base URL: https://graph.microsoft.com/v1.0. All calls require a bearer token with the permissions listed above.
1. List risk detections in a time window
GET /identityProtection/riskDetections?$filter=activityDateTime ge {start_iso} and activityDateTime le {end_iso}&$orderby=activityDateTime desc&$top=200Returns risk events such as unfamiliarFeatures, anonymizedIPAddress, maliciousIPAddress, atypicalTravel, and leakedCredentials, with user, location, IP, and risk level.
2. List currently risky users
GET /identityProtection/riskyUsers?$filter=riskState eq 'atRisk' or riskState eq 'confirmedCompromised'3. Pull all sign-ins for the window (success and failure)
GET /auditLogs/signIns?$filter=createdDateTime ge {start_iso} and createdDateTime le {end_iso}&$orderby=createdDateTime desc&$top=500Follow @odata.nextLink for pagination. Select the fields you need to reduce the payload: &$select=id,createdDateTime,userPrincipalName,userId,ipAddress,location,status,riskLevelDuringSignIn,riskEventTypes,deviceDetail,appDisplayName.
4. Drill into one user's timeline
GET /auditLogs/signIns?$filter=userId eq '{userId}' and createdDateTime ge {start} and createdDateTime le {end}&$orderby=createdDateTime asc5. Remediation calls
# Revoke all active refresh tokens
POST /users/{userId}/revokeSignInSessions
# Disable the account
PATCH /users/{userId}
Content-Type: application/json
{ "accountEnabled": false }
# Mark user as compromised in Identity Protection
POST /identityProtection/riskyUsers/confirmCompromised
Content-Type: application/json
{ "userIds": ["{userId}"] }Triage logic
Client-side, join the three datasets by userId and compute per-user metrics: total attempts, failure count, distinct countries, distinct IPs, distinct ASNs, and whether any sign-in had a riskLevelDuringSignIn of medium or high. Example flagging rule, which you should tune to your tenant: flag a user as suspicious when the failure count passes your failure threshold, when sign-ins come from two or more countries within a short window, or when any medium or high risk sign-in is present.
PowerShell
Prerequisites
- PowerShell 7 or later is recommended.
Install-Module Microsoft.Graph -Scope CurrentUser.- Run with an account that has at least the Security Reader directory role (read-only review) or Security Administrator (for remediation).
Approach
- Connect with
Connect-MgGraph, requesting the read scopes, plus the write scopes only if you plan to remediate. - Define the date range (for example, the most recent weekend).
- Retrieve risk detections, risky users, and sign-in logs for that range by using the Microsoft Graph PowerShell cmdlets for each.
- Group the sign-ins by user and compute failures, countries, IPs, and a risk score.
- Print a summary. If you remediate, confirm each flagged user individually before you revoke sessions.
Interpreting the output
Define your own risk score bands and document them. Always correlate country and IP changes against the user's declared travel or out-of-office status before you take action.