Skip to content

A simple application I've created that allows users from a business, university, or organization to check the activity status of a user's Microsoft Teams account (Yes, you can upload multiple users). I have included a tool that detects if the user has retired from the organization or is still an active member/employee.

License

Notifications You must be signed in to change notification settings

0xlithe/Microsoft-Teams-Activity-Monitor

Repository files navigation

Microsoft Teams Activity Monitor

A comprehensive web-based tool for monitoring Microsoft Teams user activity and detecting retired & inactive users in your organization.

Features

1. Teams Activity Lookup Tool

  • Check individual user's Teams presence and activity status
  • Real-time presence detection (Available, Away, Busy, Offline)
  • Last activity timestamp tracking
  • History of recent lookups
  • Export results to clipboard

2. Retired User Detector

  • Advanced scoring algorithm to identify retired employees.
  • Single user or bulk analysis (up to 50 users)
  • Multi-factor retirement risk assessment including:
    • Account status (enabled/disabled)
    • Last sign-in activity
    • Teams presence and activity
    • License assignments
    • Group memberships

3. PowerShell Guide

  • Comprehensive step-by-step instructions for Teams management via PowerShell
  • Code snippets with copy functionality
  • Permission requirements and setup

Prerequisites

  • Node.js 14.0+
  • Microsoft 365 Organization User with Global Reader permissions
  • Microsoft Graph API access with appropriate permissions

Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/TeamsActivityMonitor.git
cd TeamsActivityMonitor

2. Install Dependencies

npm install
# or
yarn install

3. Configure Environment Variables

Copy the .env.example file to .env:

cp .env.example .env

Edit the .env file and add your Microsoft User credentials:

MICROSOFT_CLIENT_ID=your_client_id_here
MICROSOFT_CLIENT_SECRET=your_client_secret_here
MICROSOFT_TENANT_ID=your_tenant_id_here

4. Run the Development Server

npm run dev
# or
yarn dev

Open http://localhost:3000 in your browser.

Setting Up Microsoft Graph API Access

Step 1: Register an App in Azure Portal

  1. Go to Azure Portal
  2. Navigate to Azure Active DirectoryApp registrations
  3. Click New registration
  4. Configure your app:
    • Name: Teams Activity Monitor
    • Supported account types: Accounts in this organizational directory only
    • Redirect URI: Leave blank for now
  5. Click Register

Step 2: Configure API Permissions

  1. In your app registration, go to API permissions
  2. Click Add a permissionMicrosoft Graph
  3. Choose Application permissions
  4. Add these permissions:
    • User.Read.All - Read all users' profiles
    • Presence.Read.All - Read presence information
    • Reports.Read.All - Read usage reports
    • Directory.Read.All - Read directory data
  5. Click Grant admin consent (requires admin privileges)

Step 3: Create Client Secret

  1. Go to Certificates & secrets
  2. Click New client secret
  3. Add a description and select expiry period
  4. Click Add
  5. Copy the secret value immediately (it won't be shown again)

Step 4: Get Your Credentials

From the app overview page, copy:

  • Application (client) IDMICROSOFT_CLIENT_ID
  • Directory (tenant) IDMICROSOFT_TENANT_ID
  • Your copied secret → MICROSOFT_CLIENT_SECRET

Alternative: Microsoft 365 admin center

Go to admin.microsoft.com and sign in.

Left menu: Show all → Roles.

Search Global Reader, open it → Assigned admins. Look for your name.

Or: Users → Active users → open your user → Account tab → Roles → see Admin center access list for Global Reader.

Tip: If you can’t open the admin center, you likely don’t have any admin role (including Global Reader).

📱 Usage Guide

Teams Activity Lookup

  1. Navigate to /teams-activity-lookup
  2. Enter a username or email address
  3. Click "Lookup" to check their current Teams status
  4. View presence, activity, and last activity time
  5. Copy results or check history of recent lookups

Retired User Detector

  1. Navigate to /retired-user-detector
  2. Choose between:
    • Single User: Enter one email address
    • Bulk Analysis: Paste up to 50 email addresses (one per line)
  3. Click "Analyze" to run the detection algorithm
  4. Review retirement risk scores and recommendations
  5. Export results to CSV for reporting

PowerShell Guide

  1. Navigate to /powershell-guide
  2. Follow the step-by-step instructions
  3. Copy code snippets as needed
  4. Use for advanced Teams management tasks

Retirement Detection Algorithm

The tool uses a weighted scoring system to assess retirement risk:

Indicator Weight Description
Account Status 30% Checks if account is disabled or blocked
Last Sign-in 25% Days since last authentication
Teams Activity 20% Recent Teams presence and activity
License Status 15% Active licenses and usage
Group Membership 10% Active directory and security groups

Development

Project Structure

├── src/
│   ├── app/
│   │   ├── teams-activity-lookup/    # Activity lookup tool
│   │   ├── retired-user-detector/    # Retirement detection tool
│   │   └── powershell-guide/         # PowerShell documentation
│   ├── api/
│   │   └── teams-activity/           # API routes for Teams data
│   └── components/                   # Reusable React components
├── public/                           # Static assets
└── package.json                      # Dependencies and scripts

Technology Stack

  • Frontend: Next.js 14, React 18, TailwindCSS
  • API Integration: Microsoft Graph API
  • Deployment: Vercel-ready

API Endpoints

POST /api/teams-activity

Check Teams activity for a specific user.

Request Body:

{
  "username": "[email protected]"
}

Response:

{
  "username": "[email protected]",
  "displayName": "John Doe",
  "lastActivity": "2024-01-27T10:30:00Z",
  "presence": {
    "availability": "Available",
    "activity": "Available"
  },
  "timestamp": "2024-01-27T10:35:00Z"
}

Troubleshooting

Common Issues

"Failed to authenticate with Microsoft Graph API"

  • Verify your environment variables are set correctly
  • Check that your client secret hasn't expired
  • Ensure admin consent has been granted for API permissions

"User not found"

  • Verify the email address is correct
  • Check that the user exists in your Microsoft 365 tenant
  • Ensure you have User.Read.All permission

Rate Limiting

  • The tool includes built-in rate limiting for bulk operations
  • If you encounter throttling, reduce batch sizes or add delays

Support

For issues, questions, or suggestions, please:

Disclaimer

This tool is designed for legitimate administrative purposes only. Ensure you have proper authorization before monitoring user activity in your organization. Always comply with your organization's privacy policies and local regulations regarding employee monitoring.


Note: Currently, the tool displays simulated data for demonstration purposes. Connect your Microsoft Graph API credentials to enable real-time Teams activity monitoring.

About

A simple application I've created that allows users from a business, university, or organization to check the activity status of a user's Microsoft Teams account (Yes, you can upload multiple users). I have included a tool that detects if the user has retired from the organization or is still an active member/employee.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published