A PowerShell script to list, block, and unblock Microsoft 365 Copilot agents via the M365 Admin Center API.
The M365 Admin Center provides a UI for managing Copilot agents, but no documented PowerShell cmdlets exist for this purpose. This script authenticates using the Azure PowerShell module and calls the same internal APIs that the Admin Center UI uses, enabling bulk management and automation scenarios.
- PowerShell 7+ (pwsh)
- Az.Accounts module — installed automatically on first run if missing
- An account with Global Administrator or equivalent admin permissions in the target tenant
# List all agents across all scopes (default)
.\Manage-CopilotAgents.ps1 -TenantId "contoso.onmicrosoft.com"
# List agents from specific scopes only
.\Manage-CopilotAgents.ps1 -TenantId "contoso.onmicrosoft.com" -AgentScopes Shared,Tenant
# Block agents interactively
.\Manage-CopilotAgents.ps1 -TenantId "contoso.onmicrosoft.com" -Action Block
# Unblock agents interactively
.\Manage-CopilotAgents.ps1 -TenantId "12345678-1234-..." -Action Unblock| Parameter | Required | Default | Description |
|---|---|---|---|
TenantId |
Yes | — | Azure AD / Entra ID tenant ID (GUID or domain name) |
Action |
No | List |
Action to perform: List, Block, or Unblock |
AgentScopes |
No | All scopes | Which agent scopes to query. Valid values: Shared, Public, Tenant, EntraAgentBlueprintSP |
The script queries multiple scopes to match the Admin Center UI behavior:
| Scope | Workload | Description |
|---|---|---|
Shared |
SharedAgent |
Agents created with Agent Builder and shared within the org |
Public |
MetaOS |
Publicly available third-party and first-party agents |
Tenant |
MetaOS |
Tenant-scoped agents |
EntraAgentBlueprintSP |
EntraAgentBlueprintSP |
Entra-based agent blueprints |
The script uses the Az PowerShell module (Az.Accounts) for authentication:
- On first run, it calls
Connect-AzAccountwhich opens a browser for interactive sign-in. - It then requests an access token scoped to
https://admin.microsoft.com. - Subsequent runs reuse the existing Az context if the tenant matches.
All non-auth API requests and responses are logged to a date-stamped file in the script directory:
copilot-agents-2026-03-20.log
The log captures the HTTP method, URL, request body (for POST), and response body for each API call. Large responses are truncated at 50KB.
- List agents —
GET /fd/addins/api/agents?workloads={workload}&scopes={scope}&limit=200 - Block/Unblock agents —
POST /fd/addins/api/availableAgentswith aWorkloadManagementListpayload containing the agent identifiers and theBLOCKorUNBLOCKcommand.
When blocking or unblocking, the script displays a numbered table of agents and prompts for selection:
- Enter comma-separated numbers (e.g.,
1,3,5) - Enter
allto select all agents - Enter
qto cancel
A confirmation prompt (yes) is required before any block or unblock operation executes.
This tool uses undocumented internal APIs from the M365 Admin Center. These APIs may change without notice. Use at your own risk.
MIT