Skip to main content

Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams

Workflow preview

Workflow preview
100%
Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams preview
Open on n8n.io

1. Workflow Overview

Quick overview This template runs two scheduled workflows to govern Microsoft Entra ID (Azure AD) guest accounts by detecting stale users via Microsoft Graph, staging deletions in SharePoint with a...

Best for

  • SecOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.code, n8n-nodes-base.microsoftsharepoint, n8n-nodes-base.microsoftteams, n8n-nodes-base.if, n8n-nodes-base.microsoftentra, n8n-nodes-base.noop, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mychel Garzon.

Original n8n.io source

1.1 Workflow description

Title
Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams
Workflow name
Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams

Quick overview

This template runs two scheduled workflows to govern Microsoft Entra ID (Azure AD) guest accounts by detecting stale users via Microsoft Graph, staging deletions in SharePoint with a 72-hour window, notifying sponsors in Microsoft Teams, and deleting overdue guests while auditing outcomes.

How it works

  1. The Scanner (Runs Weekly): Fetches all guest users using native Microsoft Graph API pagination.
  2. Filters Stale Accounts: Identifies guests with no sign-in activity for over 90 days.
  3. Stages Deletions: Writes new stale accounts to a SharePoint PendingGuestDeletions list with a 72-hour countdown.
  4. Alerts Sponsors: Mentions the assigned manager in a Microsoft Teams message, warning them of the impending deletion.
  5. The Executioner (Runs Daily): Queries SharePoint for records where the 72-hour countdown has expired.
  6. Checks Exceptions: Verifies if the sponsor added the guest to a SharePoint GuestRetentionExceptions list.
  7. Deletes & Audits: Safely deletes the Entra ID account (if not retained), updates the staging list status, and logs the final outcome to an Audit SharePoint list.

Setup

  1. SharePoint: Create three lists: PendingGuestDeletions, GuestRetentionExceptions, and GuestAccountAuditLog (ensure columns match the workflow JSON).
  2. Azure AD: Create an App Registration with User.ReadWrite.All, AuditLog.Read.All, Sites.ReadWrite.All, and ChannelMessage.Send (Application permissions).
  3. n8n Credentials: Connect your OAuth2 (Client Credentials) setup to the "MS Graph - Guest Governance" credential.
  4. Configuration: Open the two Config nodes (Scanner and Executioner) and paste your SharePoint Site ID, List IDs, and Teams Team/Channel IDs.
  5. Error Handler: Go to Workflow Settings and bind your preferred Error Handler workflow to catch API routing failures.

Requirements

  • Microsoft Entra ID (Azure AD) tenant
  • Microsoft SharePoint (for database state management)
  • Microsoft Teams (for sponsor alerts)
  • Azure App Registration with Application-level Graph API permissions

Customization

  • Modify the inactivityThresholdDays (default 90) and responseWindowHours (default 72) in the Config nodes.
  • Adjust the Teams message HTML payload to match your internal IT branding.
  • Change the Cron triggers to match your specific IT operational cadence.

Additional info

This template completely avoids the severe limitations of long-running 72-hour Wait nodes by decoupling the discovery and deletion phases into two distinct workflows bridged by a SharePoint database. Combined with native node pagination and built-in rate-limit retries, this engine is highly resilient and safe to run in massive enterprise tenants with tens of thousands of guest users.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Scanner Section

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Split Pending Items

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Executioner Section 5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Executioner Section 4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Executioner Section 3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Executioner Section 2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Executioner Section 1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Scanner Section 3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Scanner Section 2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Scanner Section 1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Mark Pending as Error

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 12 - Log Retention to Teams

Type / Role
n8n-nodes-base.microsoftTeams - microsoftTeams
Config choices
Version 2

Block 13 - Mark Pending as Retained

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 14 - Delete Error Alert

Type / Role
n8n-nodes-base.microsoftTeams - microsoftTeams
Config choices
Version 2

Block 15 - Mark Pending as Deleted

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 16 - Log Deletion to Audit List

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 17 - Delete Succeeded?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 18 - Delete Stale Guest Account

Type / Role
n8n-nodes-base.microsoftEntra - microsoftEntra
Config choices
Version 1

Block 19 - Retention Exception?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 20 - Check Retention Exception

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 21 - Nothing Due Today

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 22 - Any Due For Deletion?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 23 - Get Overdue Pending Deletions

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 24 - Config (Executioner)

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Showing the first 24 of 74 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams
Complexity advanced
Nodes 74
Categories SecOps
Author Mychel Garzon
Published 31 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16041/16041.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Govern stale Entra ID guest accounts with SharePoint and Microsoft Teams do?

Quick overview This template runs two scheduled workflows to govern Microsoft Entra ID (Azure AD) guest accounts by detecting stale users via Microsoft Graph, staging deletions in SharePoint with a...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.