--- title: "Audit 90-Day Inactive M365 Users and Build a Safe Deprovisioning Plan" slug: "dex-wf-audit-inactive-users-deprovisioning-plan" updated: 2026-11-30T16:16:25Z published: 2026-11-30T16:16:25Z canonical: "documentation.sysaid.com/dex-wf-audit-inactive-users-deprovisioning-plan" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Audit 90-Day Inactive M365 Users and Build a Safe Deprovisioning Plan Identify stale accounts with real activity data from Exchange, SharePoint, OneDrive, and Teams, then phase deprovisioning with manager notification. **Complexity:** Intermediate. **Impact:** cost-savings + security + governance + compliance + license-optimization. ## Why use this workflow Inactive user accounts are one of the highest-leverage cleanup targets in a Microsoft 365 tenant. Every stale account typically carries a paid license, a live mailbox, OneDrive storage, and potentially SharePoint site ownership. Beyond cost, they are a security liability: dormant accounts are prime targets for password spray and phishing-based takeover. A 90-day inactivity audit is a common governance control. This workflow walks through how to build that audit: not just by looking at Entra sign-in logs (which miss service-specific activity), but by cross-referencing the `getOffice365ActiveUserDetail` usage report, which includes Exchange, SharePoint, OneDrive, and Teams last-activity dates. The output is not just a list. It is a phased deprovisioning plan with manager notifications, license removal recommendations, and safeguards against accidentally disabling executive or service accounts. ## Expected outcomes ### After completing this workflow you have: - A CSV report of all users inactive for 90 or more days, with per-service last-activity dates (Exchange, SharePoint, OneDrive, Teams) - License assignment details for each inactive user (critical for cost recovery) - Manager name and email for each inactive user (for the notification workflow) - A recommended action per user (review for license removal or account disable) - A phased deprovisioning plan (notify, review, disable, remove licenses) - A flag for high-risk accounts (executives, service accounts, shared mailboxes) that need HR or manual review ## Risks and considerations ### Watch out for these pitfalls - **Anonymized reports:** By default, Microsoft 365 usage reports show concealed names like `5C0DBA…`. You must temporarily set `displayConcealedNames` to `false` with `PATCH /admin/reportSettings` to get real UPNs. *Always re-enable anonymization after the audit* to stay aligned with your privacy posture. - **Do not rely on `signInActivity` alone:** It tracks only Entra interactive and non-interactive sign-ins. A user may be inactive in Entra logs but still have Exchange mail flow or OneDrive sync activity. Use the usage report for a true picture. - **Service accounts and shared mailboxes** appear as inactive because they are designed to never sign in interactively. Tag and exclude them before any disable action. - **Executive accounts** (C-suite, board members) often show low activity but should never be auto-deprovisioned. Escalate these to HR. - **Do not delete accounts directly.** The safe sequence is: notify the manager, remove licenses, disable sign-in, convert the mailbox to shared, wait for your retention period, then delete. Skipping the shared-mailbox step can lose mail data permanently. - **Licensed but never signed in:** These are often onboarding mistakes (license assigned before the user started) or offboarding failures. Investigate before you revoke. - **B2B guest users** have different activity patterns and may not appear correctly in the usage report. Handle them in a separate audit. ## Required permissions | Permission | Why it's needed | | --- | --- | | Reports.Read.All | Required to call getOffice365ActiveUserDetail and related usage reports that provide per-service activity data | | ReportSettings.ReadWrite.All | Required to temporarily disable report anonymization (displayConcealedNames) so actual UPNs and display names appear in reports | | User.Read.All | Required to fetch per-user license assignments, accountEnabled status, department, and job title | | Directory.Read.All | Required to read each user's manager relationship for the notification workflow | | Organization.Read.All | Optional: needed if you want to map license SKU GUIDs to friendly product names for the report | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` Audit our M365 tenant for users inactive {days} days. Pull activity across Exchange, SharePoint, OneDrive, and Teams - not just Entra sign-ins. For each inactive user, report license count, manager, and department. Flag executives and service-account candidates separately. Output a phased deprovisioning plan with manager notifications and a CSV I can action on. ``` ## Manual steps (admin center) The Microsoft 365 admin center provides a built-in inactive user view, though it is less detailed than the API-driven approach. ### Step 1: Disable report anonymization (one-time) 1. Sign in to the [Microsoft 365 admin center](https://admin.microsoft.com) as a Global Administrator or Reports Reader. 2. Go to **Settings** > **Org settings** > **Services** > **Reports**. 3. Clear **Display concealed user, group, and site names in all reports**. 4. Select **Save**. Reports can take time to refresh with real names. ### Step 2: Pull the active users report 1. Go to **Reports** > **Usage**. 2. Open the **Active users: Microsoft 365 Services** card. 3. Set the date range to **Last 90 days**. 4. Select **Export** to download the CSV. ### Step 3: Identify inactive users 1. Open the CSV in Excel. 2. Filter `Is Deleted` = FALSE. 3. Filter `Last Activity Date` = blank or older than 90 days ago. 4. Cross-reference with **Users** > **Active users** to confirm the account is enabled and still licensed. ### Step 4: Check SharePoint ownership 1. Go to **SharePoint admin center** > **Sites** > **Active sites**. 2. For each inactive user, filter the **Primary admin** column by their UPN. 3. Document any sites where they are the sole owner. These need reassignment before you disable the account. ### Step 5: Check mailbox size and activity 1. Go to **Exchange admin center** > **Recipients** > **Mailboxes**. 2. Search for each inactive user. 3. Review mailbox size and last logon date. Larger mailboxes warrant shared-mailbox conversion before you disable the account. ### Step 6: Notify the manager 1. Go to **Users** > **Active users**. 2. Select the user, open the **Account** tab, and note the **Manager** field. 3. Send the manager an email that asks whether the account should be retained, converted, or disabled. ### Step 7: Execute deprovisioning after confirmation 1. Remove licenses: select the user, then **Licenses and apps**, clear all licenses, and select **Save**. 2. Block sign-in: select the user, then **Account** > **Block sign-in**. 3. Convert the mailbox: **Exchange admin center** > mailbox > **Convert to shared mailbox**. 4. After your retention period, delete the user from **Users** > **Deleted users**. ### Step 8: Re-enable report anonymization Return to **Settings** > **Org settings** > **Services** > **Reports** and select the anonymization option again. ## Microsoft Graph API The end-to-end flow uses four endpoints: read report settings, toggle anonymization, pull the usage report, and enrich each inactive user with license and manager data. ### 1. Check current report anonymization setting ``` GET https://graph.microsoft.com/v1.0/admin/reportSettings // Response {  "displayConcealedNames": true } ``` ### 2. Disable anonymization (temporarily) ``` PATCH https://graph.microsoft.com/v1.0/admin/reportSettings Content-Type: application/json {  "displayConcealedNames": false } // Returns 204 No Content ``` ### 3. Pull the 90-day Office 365 activity report ``` GET https://graph.microsoft.com/v1.0/reports/getOffice365ActiveUserDetail(period='D90') // Returns CSV. Key columns: //   User Principal Name, Display Name, Is Deleted, //   Last Activity Date, Exchange Last Activity Date, //   SharePoint Last Activity Date, OneDrive Last Activity Date, //   Teams Last Activity Date, Has Exchange License, ... ``` ### 4. For each inactive user, fetch license and manager ``` GET /v1.0/users/{upn}?$select=id,assignedLicenses,accountEnabled,department,jobTitle GET /v1.0/users/{id}/manager?$select=displayName,userPrincipalName // Returns 404 if no manager is assigned - handle gracefully ``` ### 5. (Optional) Check SharePoint site ownership ``` GET /v1.0/sites?search=*&$select=id,displayName,webUrl // For each site, check owners via: GET /v1.0/sites/{site-id}/permissions ``` ### 6. Re-enable anonymization ``` PATCH https://graph.microsoft.com/v1.0/admin/reportSettings {  "displayConcealedNames": true } ``` ### Deprovisioning actions (after manager approval) ``` // Remove a license POST /v1.0/users/{upn}/assignLicense {  "addLicenses": [],  "removeLicenses": ["{skuId}"] } // Block sign-in PATCH /v1.0/users/{upn} {  "accountEnabled": false } // Revoke all refresh tokens / sessions POST /v1.0/users/{upn}/revokeSignInSessions ``` **Note:** Converting a mailbox to shared is available only through Exchange Online PowerShell (`Set-Mailbox -Type Shared`), not Graph. ## PowerShell Use the `Microsoft.Graph` PowerShell SDK to download the 90-day usage report, identify inactive users, enrich each with license and manager details, and output a CSV with deprovisioning recommendations. ### Prerequisites ``` # Install once Install-Module Microsoft.Graph -Scope CurrentUser # Connect with required scopes Connect-MgGraph -Scopes "Reports.Read.All","ReportSettings.ReadWrite.All","User.Read.All","Directory.Read.All" ``` ### Approach 1. Save the current `displayConcealedNames` setting so that you can restore it. 2. Disable report anonymization if needed. 3. Retrieve the 90-day Office 365 active user detail report and parse the CSV. 4. Filter for users where the latest activity across all services is older than 90 days (or never). 5. For each match, retrieve the user and the user's manager to enrich the row with license count, manager, and department. 6. Tag each row with a recommendation (for example `Review for license removal`, `Service account candidate`, or `Executive - escalate to HR`). 7. Export to CSV and restore the original anonymization setting.