Domain exclusion overview

By using domain exclusion, you can specify up to 1,000 sites to exclude from web grounding in Microsoft 365 Copilot and Copilot Chat through a PowerShell script.

To manage the Copilot domain exclusion configuration for your tenant, use the ConfigureTenantDomainExclusions.ps1 PowerShell script. Download it at https://aka.ms/Copilot/DomainExclusionScript. Currently, the domain exclusion configuration supports up to two levels of subdomains.

This script provides the following capabilities:

  • Get current domain exclusion configuration and export to CSV
  • Create new domain exclusion configuration from CSV file
  • Update existing domain exclusion configuration from CSV file
  • Delete current domain exclusion configuration
  • Generate a template CSV file for domain exclusions

Default settings don't include the domain exclusion configuration. Opt in to use the feature by running the PowerShell script.

Prerequisites

Before running the script, make sure you meet the following requirements:

Download the Configure Tenant Domain Exclusions PowerShell script

  1. Download the Configure Tenant Domain Exclusions PowerShell file at https://aka.ms/Copilot/DomainExclusionScript.

  2. Unzip it to a location you can access from PowerShell.

Configure your domain exclusion by using PowerShell

As you run each command, you're prompted to sign in. The system retrieves your tenant's subscriptions, runs the operation, and then displays confirmation about whether the operation completed successfully.

Generate a template CSV

Create a template CSV file to help you get started:

   .\ConfigureTenantDomainExclusions.ps1 -Template

Sample CSV content

In the following example, sample CSV content is represented by a domain followed by a Boolean value that determines whether to include domain subpages:

  • Domain,IncludeSubPages
  • https://www.example.org,True
  • example.com,False
  • https://docs.contoso.com,True

Get current configuration

Export the current domain exclusion configuration to a CSV file:

   .\ConfigureTenantDomainExclusions.ps1 -Get

By default, the script exports to domain_exclusions.csv. To export to a specific file, specify the desired name by using -ToFile as shown in the following example:

   .\ConfigureTenantDomainExclusions.ps1 -Get -ToFile "my_current_config.csv"

Create a new configuration

Create your domain exclusion configuration from a CSV file:

   .\ConfigureTenantDomainExclusions.ps1 -Create -FromFile "input.csv"

Update an existing configuration

Update your current domain exclusion configuration with entries from a CSV file:

   .\ConfigureTenantDomainExclusions.ps1 -Update -FromFile "updated_domains.csv"

Note

Updating a configuration replaces the old configuration with the newly provided one.

Delete a configuration

Remove your current domain exclusion configuration:

   .\ConfigureTenantDomainExclusions.ps1 -Delete

CSV file format

When creating or updating domain exclusions, your CSV file must include the following columns:

Column Description Example values
Domain The domain or URL to block example.com

https://www.example.org/path

https://docs.contoso.com
IncludeSubPages Whether to include all subpages True

False

Common issues and troubleshooting

Limitations

Currently, domain exclusions support filtering on web page results only. Results from other answer verticals, such as news, might still be cited.

Execution policy errors

If you receive an error about execution policies when trying to run the script, you might need to temporarily set your execution policy to Unrestricted:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted

For more information about PowerShell execution policies, see the PowerShell execution policy documentation.

Authentication issues

If you encounter authentication errors:

  1. Ensure you're signed in as a Search Administrator or Global Administrator.

  2. Try disconnecting and reconnecting your Azure account:

    powershell Disconnect -AzAccount Connect -AzAccount
    

CSV validation errors

If you receive CSV validation errors, check these things:

  • Invalid domains: Ensure all domain entries are valid URLs or domain names.
  • Missing columns: Verify your CSV has both Domain and IncludeSubPages columns.
  • Too many entries: Ensure your CSV has no more than 1,000 entries.
  • Boolean values: Ensure IncludeSubPages contains only True or False values.

More information

For more information about PowerShell execution policies, see About execution policies.