Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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:
Administrative permissions:
- You must sign in as a Search Administrator or Global Administrator.
- See About administrator roles in the Microsoft 365 admin center.
PowerShell requirements:
- Windows PowerShell 5.1 or PowerShell 7+. (See PowerShell 101 introduction)
- Az.Accounts PowerShell module (the
ConfigureTenantDomainExclusions.ps1script installs it automatically if it's missing). - Execution policy set to allow script execution (see Execution policy errors).
CSV file requirements (for Create/Update operations):
- Maximum of 1,000 entries per CSV file.
- Required columns:
Domain,IncludeSubPages. - Domain values should be valid domains or URLs (for example,
https://www.example.org). IncludeSubPagesvalues should be Boolean (True/False).- See Generate a template CSV (in this article).
Download the Configure Tenant Domain Exclusions PowerShell script
Download the Configure Tenant Domain Exclusions PowerShell file at https://aka.ms/Copilot/DomainExclusionScript.
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,Trueexample.com,Falsehttps://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.comhttps://www.example.org/pathhttps://docs.contoso.com |
| IncludeSubPages | Whether to include all subpages | TrueFalse |
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:
Ensure you're signed in as a Search Administrator or Global Administrator.
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
DomainandIncludeSubPagescolumns. - Too many entries: Ensure your CSV has no more than 1,000 entries.
- Boolean values: Ensure
IncludeSubPagescontains onlyTrueorFalsevalues.
More information
For more information about PowerShell execution policies, see About execution policies.