IAMinerva
HomeBlogAbout
m3M365 NewscoMicrosoft CopilotteMicrosoft TeamsshSharePoint & OneDriveinIntune & SecurityexExchange & OutlookpoPower PlatformazAzure & Entra IDtuTutorials & GuidesevEvents & ConferencesseSecuritywiWindows
IAMinerva

Professional blog dedicated to the Microsoft 365 ecosystem.

Quick links

HomeBlogAboutNewsletter

Stay informed

Get the latest Microsoft 365 news delivered straight to your inbox.

© 2026 IAMinerva. All rights reserved.

Built withNext.js&Tailwind
Exécution de scripts PowerShell pour auditer des applications AI et gérer leurs enregistrements.
BlogMicrosoft CopilotAudit and Manage AI Applications with PowerShell
Microsoft Copilot#PowerShell#Microsoft Graph#Entra ID

Audit and Manage AI Applications with PowerShell

Audit unauthorized AI applications in Entra ID with PowerShell and Microsoft Graph to strengthen control and security.

Houssem MAKHLOUF
June 28, 2026
4 min read

TL;DR par Minerva

généré par IA

Audit unauthorized AI applications in Entra ID with PowerShell and Microsoft Graph to strengthen control and security.

Introduction

The proliferation of AI tools can quickly become a governance issue in enterprise environments. Employees often test new applications, grant consent to browser plugins, and in no time, security teams are faced with a multitude of unauthorized services. This technical article proposes a practical and detailed solution using Microsoft Entra ID, Microsoft Graph, and Microsoft Defender for Cloud Apps to audit and manage these AI applications.

i

Good to Know

Thanks to Microsoft Entra ID and associated Microsoft tools, you can collect valuable data to analyze suspicious applications and establish a governance strategy.

In this guide, you will learn how to create a PowerShell audit to identify AI applications, assess risks, and produce an actionable governance report.

Prerequisites

To follow this tutorial, make sure you have the following:

  • PowerShell 7 or Windows PowerShell 5.1.
  • Microsoft Graph PowerShell SDK installed.
  • A Microsoft Entra account with the necessary permissions to read applications and audit logs.
  • Microsoft Graph consent for the required roles described below.
  • Optional: Microsoft Defender for Cloud Apps to monitor network activity.
!

Warning

The scripts and examples presented here are in read-only mode: they do not exclude applications or modify permissions.

Understanding Microsoft Graph Limitations

Microsoft Graph provides a powerful view of AI interactions via Microsoft Entra ID, including:

  • Enterprise applications.
  • Delegated OAuth permissions.
  • Application permissions.
  • Recent sign-in activities.

However, Graph cannot capture visits to external AI sites when Microsoft Entra ID is not used. For this, combine Graph data with network telemetry or Microsoft Defender for Cloud Apps CASB capabilities.

Two Analysis Paths

  • Identity Path: Analysis of identity objects such as permissions, consents, or sign-ins in Entra ID.
  • Network Path: Monitoring of AI destinations accessed without Entra ID involvement.

We will start with the identity path.

Installing and Connecting to the Microsoft Graph SDK

Install the Microsoft Graph PowerShell module and connect with the minimum permissions needed for auditing.

⚡PowerShell
1Install-Module Microsoft.Graph -Scope CurrentUser
2
3$Scopes = @(
4 'Application.Read.All',
5 'Directory.Read.All',
6 'AuditLog.Read.All'
7)
8
9Connect-MgGraph -Scopes $Scopes

Verify the connection context to ensure the necessary scopes are applied:

⚡PowerShell
1Get-MgContext | Select-Object Account, TenantId, Scopes

Creating an AI Keywords List

To identify AI applications, create a keyword list based on product and vendor names related to AI.

⚡PowerShell
1$ReportPath = Join-Path $HOME 'AI-App-Audit'
2New-Item -Path $ReportPath -ItemType Directory -Force | Out-Null
3
4$AiKeywords = @(
5 'openai', 'chatgpt', 'copilot', 'claude', 'anthropic', 'gemini',
6 'bard', 'perplexity', 'midjourney', 'stability', 'jasper',
7 'notion ai', 'grammarly', 'otter', 'fireflies', 'descript', 'synthesia'
8)
✦

Tip

Regularly update your keyword list to reflect emerging products and your organization's specific needs.

Identifying AI Applications in Entra ID

Use the keywords to filter applications registered in your tenant.

⚡PowerShell
1$ServicePrincipals = Get-MgServicePrincipal -All -Property @(
2 'id', 'appId', 'displayName', 'appOwnerOrganizationId',
3 'accountEnabled', 'createdDateTime', 'publisherName',
4 'servicePrincipalType', 'tags'
5)
6
7$AiServicePrincipals = foreach ($Sp in $ServicePrincipals) {
8 $SearchText = @(
9 $Sp.DisplayName, $Sp.PublisherName, $Sp.AppId, ($Sp.Tags -join ' ')
10 ) -join ' '
11
12 $Matches = $AiKeywords | Where-Object {
13 $SearchText -match [regex]::Escape($_)
14 }
15
16 if ($Matches) {
17 [pscustomobject]@{
18 DisplayName = $Sp.DisplayName
19 PublisherName = $Sp.PublisherName
20 AppId = $Sp.AppId
21 ObjectId = $Sp.Id
22 AccountEnabled = $Sp.AccountEnabled
23 CreatedDateTime = $Sp.CreatedDateTime
24 ServicePrincipalType = $Sp.ServicePrincipalType
25 MatchedKeywords = ($Matches -join ', ')
26 }
27 }
28}
29
30$AiServicePrincipals |
31 Sort-Object DisplayName |
32 Export-Csv -Path (Join-Path $ReportPath 'ai-service-principals.csv') -NoTypeInformation
×

Important

Collected data must be validated by an administrator before any action. Verify user contexts and permissions of listed applications.

Next Steps

Continue your audit by exploring:

  • OAuth delegated permissions to understand access granted to users.
  • Application permissions to identify service-level access.
  • Recent sign-ins to detect suspicious activities.
1

Audit delegated permissions

Use Get-MgOauth2PermissionGrant to examine types of delegated consents.

2

Verify application-level permissions

Apply Invoke-MgGraphRequest to extract assigned application roles.

3

Analyze recent sign-ins

Query Get-MgAuditLogSignIn with a time filter.

Conclusion

Managing AI applications within Microsoft Entra ID is not just a simple configuration. With PowerShell, you can automate discovery, auditing, and governance using Microsoft Graph data and, if needed, complement this analysis with Defender for Cloud Apps to monitor network interactions.

Adopt a proactive approach by applying these scripts on a regular basis, adjusting keywords, and using generated reports to validate, restrict, or approve AI tools. Thus, you will transform a potential sprawl into a targeted governance opportunity.

Share:
HM

Houssem MAKHLOUF

Microsoft 365 enthusiast & IT professional.

Previous article

Cloud native and agentic AI: an essential duo

Jun 28, 2026
Next article

Agents: Transforming Work with AI in Microsoft 365

Jun 28, 2026

Related articles

Paysages montagneux avec des formes géométriques dorées sur un fond sombre.copilot

Microsoft Cloud, AI and Security Certifications: Anticipate 2026

Discover the new Microsoft certifications for cloud, AI and security. Anticipate these changes to remain competitive in 2026.

Jun 29, 20263 min
Engrenage doré avec des lignes fluides lumineuses sur fond sombre.copilot

Understanding and Using Claude Skills for Automation

Learn how to use Claude Skills to automate your professional tasks with flexible AI and custom connectors.

Jun 29, 20265 min
Fluides lumineuses dorées avec des bulles de dialogue sur fond noir.copilot

Copilot Memory: Essential Updates for Users

Explore the essential updates to Copilot Memory and conversation persistence. Optimize your use of Microsoft 365 Copilot.

Jun 29, 20265 min