Microsoft 365: PowerShell – How to enable / disable Knowledge Agents

PowerShell script for Knowledge Agent feature
PowerShell script for Knowledge Agent feature

Hi All,

Greetings for the day!!!

In the last article we discussed the new feature – Knowledge Agents. Microsoft 365 : Introducing Knowledge Agent (preview): AI-powered content optimization for SharePoint and Copilot

In this article, we will discuss how to enable or disable Knowledge Agents feature using PowerShell.

We use KnowledgeAgent parameters in Set-SPOTenant to enable Knowledge Agent across all sites or selectively exclude specific ones.

Prerequisites

  • SharePoint Online Management Shell version 16.0.26413.12010 or later
  • Microsoft 365 Copilot license

Detailed Steps

  • Verify if require module “Microsoft.Online.SharePoint.PowerShell” is installed
  • Check the required version is installed
  • We will use Get-Module CMDLET
PS C:\> Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable -Verbose
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Online.SharePoint.PowerShell.
VERBOSE: Loading module from path 'C:\PowerShell\Modules\Microsoft.Online.SharePoint.PowerShell\16.0.26413.12010\Microsoft.Online.SharePoint.PowerShell.dll'.

    Directory: C:\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     16.0.2641…            Microsoft.Online.SharePoint.PowerS… Desk

  • Sometime, we didnt see complete version number.
  • We could use only “Version” property to verify the version
PS C:\> $spo_version = Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable -Verbose
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Online.SharePoint.PowerShell.
VERBOSE: Loading module from path 'C:\PowerShell\Modules\Microsoft.Online.SharePoint.PowerShell\16.0.26413.12010\Microsoft.Online.SharePoint.PowerShell.dll'.
PS C:\> $spo_version.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
16     0      26413  12010

PS C:\>

PowerShell window displaying SharePoint Online module version details, highlighting Major, Minor, Build, and Revision numbers.
Image 1: SharePoint Online PowerShell version check
  • From above CMDLET, we know that we have “SharePoint Online PowerShell” module version is – 16.0.26413
  • NEXT, import the module: Microsoft.Online.SharePoint.PowerShell

We have detailed article to explore PowerShell modules. Please have a look once. https://knowledge-junction.in/2022/12/12/__trashed-2/

PS C:\> Import-Module -Name  "C:\PowerShell\Modules\Microsoft.Online.SharePoint.PowerShell" -UseWindowsPowerShell
WARNING: The names of some imported commands from the module 'Microsoft.Online.SharePoint.PowerShell' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
WARNING: The names of some imported commands from the module 'Microsoft.Online.SharePoint.PowerShell' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
WARNING: The names of some imported commands from the module 'Microsoft.Online.SharePoint.PowerShell' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
WARNING: Module Microsoft.Online.SharePoint.PowerShell is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell please use 'Import-Module -SkipEditionCheck' syntax.

Screenshot of PowerShell showing commands for verifying and importing the SharePoint Online PowerShell module along with warnings about unapproved verbs.
Image 2: Importing SharePoint online PowerShell module

  • NEXT, Connect to our tenant using Connect-SPOService CMDLET

PS C:\> Connect-SPOService -Url https://knowledgejunction1-admin.sharepoint.com -Credential $Cred

Screenshot of PowerShell showing credential request and command to connect to SharePoint Online service.
Image 3: Connecting to our tenant
  • To enable / disable “Knowledge Agent” feature we will use “KnowledgeAgentScope ” parameter to Set-SPOTenant CMDLET
  • Possible values for “KnowledgeAgentScope ” parameter
    • AllSites: Knowledge Agent is available on all sites.
    • ExcludeSelectedSites: Knowledge Agent is available on all sites except those specified in KnowledgeAgentSelectedSitesList.
    • NoSites: Knowledge Agent isn’t available on any sites. (This is the Default value.)
  • We can verify current status of “Knowledge Agent” feature using Get-SPOTenant CMDLET as in code below

# Verify the configuration
Get-SPOTenant | Select-Object KnowledgeAgentScope

PS C:\> Get-SPOTenant | Select-Object KnowledgeAgentScope

KnowledgeAgentScope
-------------------
NoSites

PS C:\>

PowerShell window displaying command input and output related to SharePoint Online tenant credentials and KnowledgeAgentScope configuration.
Image 4: Verify if “Knowledge Agent” feature is enabled in our Tenant

  • From the above code output it seems “Knowledge Agent” feature is disabled in my local tenant
  • As discussed, we can enable the “Knowledge Agent” feature using Set-SPOTenant CMDLET as in code below.
  • In code below, we are enabling this feature for all sites.

PS C:\> Set-SPOTenant -KnowledgeAgentScope AllSites
Set-SPOTenant: You do not have the required license to perform this operation.
PS C:\>

PowerShell command line interface displaying a credential request and commands for connecting to SharePoint and setting the Knowledge Agent scope.
Image 5: Enabling “Knowledge Agent” feature for all sites in our Tenant
  • As in my development environment I do not have Microsoft 365 copilot license, I am getting an above warning.

REFERENCES

Microsoft 365 : Introducing Knowledge Agent (preview): AI-powered content optimization for SharePoint and Copilot

PowerShell – Exploring Module CMDLETs – https://knowledge-junction.in/2022/12/12/__trashed-2/

Get started with Knowledge Agent (preview) – https://learn.microsoft.com/en-us/sharepoint/knowledge-agent-get-started#enable-knowledge-agent

Thanks for reading 🙂 LIFE IS BEAUTIFUL 🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome to discuss.

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.