Skip to content

Control 2.6: Copilot Web Search and Web Grounding Controls — PowerShell Setup

Automation scripts for managing Copilot web search and grounding controls.

Prerequisites

  • Microsoft Graph PowerShell SDK
  • Entra Global Admin or AI Administrator role
  • Microsoft 365 Admin Center API access

Scripts

Script 1: Check Web Search Configuration

# Verify Copilot web search configuration with the Graph beta tenant-level setting
# Requires: Microsoft Graph SDK

Connect-MgGraph -Scopes "CopilotPolicySettings.Read","Organization.Read.All"

# Check tenant Copilot settings
$org = Get-MgOrganization
Write-Host "=== Copilot Web Search Configuration ==="
Write-Host "Tenant: $($org.DisplayName)"
Write-Host ""
Write-Host "NOTE: Web search is managed by the 'Allow web search in Copilot' Cloud Policy."
Write-Host "Configure at: https://config.office.com > Customization > Policy Management"
Write-Host "Shortcut: Admin Center > Copilot > Settings > Data Access > Web search"
Write-Host ""
try {
    $setting = Invoke-MgGraphRequest -Method GET `
        -Uri "https://graph.microsoft.com/beta/copilot/admin/policySettings/microsoft.copilot.allowwebsearch"

    Write-Host "Graph beta setting ID: $($setting.id)"
    Write-Host "Tenant-level raw value: $($setting.value)"
    Write-Host "Tenant-level policy ID: $($setting.policyId)"
    Write-Host "NOTE: Microsoft Learn documents this as a beta, tenant-level-only endpoint. Public docs do not publish a value map for the three Cloud Policy UI options; reconcile the raw value to the UI in this tenant."
}
catch {
    Write-Warning "Unable to read microsoft.copilot.allowwebsearch through Graph beta: $($_.Exception.Message)"
    Write-Warning "Use the Cloud Policy UI as the authoritative admin configuration record."
}
Write-Host ""
Write-Host "Recommended FSI setting: DISABLED for all users"
# Audit Teams apps and plugins that access web content
# Requires: Microsoft Teams PowerShell module

Import-Module MicrosoftTeams
Connect-MicrosoftTeams

$apps = Get-TeamsApp | Where-Object {
    $_.DisplayName -match "Web|Browse|Search|Internet|Bing"
}

$webApps = @()
foreach ($app in $apps) {
    $webApps += [PSCustomObject]@{
        Name          = $app.DisplayName
        AppId         = $app.Id
        Publisher     = $app.Publisher
        Distribution  = $app.DistributionMethod
    }
}

Write-Host "=== Web-Related Apps/Plugins ==="
if ($webApps.Count -gt 0) {
    $webApps | Format-Table Name, Publisher, Distribution -AutoSize
} else {
    Write-Host "No web-related apps detected."
}
$webApps | Export-Csv "WebPlugins_$(Get-Date -Format 'yyyyMMdd').csv" -NoTypeInformation

Script 3: Monitor for Web Search Usage in Audit Logs

# Search audit logs for Bing-backed web search activity in Copilot interactions
# Requires: Security & Compliance PowerShell
# Microsoft documents Bing web search as an entry in CopilotEventData.AISystemPlugin

Import-Module ExchangeOnlineManagement
Connect-IPPSSession

$startDate = (Get-Date).AddDays(-30).ToString("MM/dd/yyyy")
$endDate = (Get-Date).ToString("MM/dd/yyyy")

$webSearchEvents = Search-UnifiedAuditLog -StartDate $startDate -EndDate $endDate `
    -RecordType "CopilotInteraction" -ResultSize 5000

$webGrounded = @()
foreach ($event in $webSearchEvents) {
    $data = $event.AuditData | ConvertFrom-Json
    if ($data.CopilotEventData.AISystemPlugin.Id -contains 'BingWebSearch') {
        $webGrounded += [PSCustomObject]@{
            Date     = $event.CreationDate
            User     = $event.UserIds
            Activity = $event.Operations
            AppHost  = $data.CopilotEventData.AppHost
        }
    }
}

Write-Host "Web-grounded Copilot interactions (last 30 days): $($webGrounded.Count)"
if ($webGrounded.Count -gt 0) {
    Write-Host "WARNING: Web search activity detected. Review governance policy."
    $webGrounded | Export-Csv "WebSearchUsage_$(Get-Date -Format 'yyyyMMdd').csv" -NoTypeInformation
}

Schema reference

Microsoft documents the CopilotEventData properties (including AppHost, Contexts, AccessedResources, and AISystemPlugin) in Copilot interaction events overview. Organizations should verify the current schema before relying on any single property, and should corroborate results with Microsoft Purview DSPM for AI activity explorer.

Scheduled Tasks

Task Frequency Purpose
Web Search Config Check Weekly Verify web search remains disabled; if using Graph beta, reconcile the raw tenant-level value to the Cloud Policy UI
Web Plugin Audit Monthly Detect new web-accessing plugins
Web Search Usage Monitor Weekly Alert on any web search activity

Next Steps