Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Last active September 30, 2025 14:38
Show Gist options
  • Select an option

  • Save joerodgers/25c8a85796f6e19a31d4fb9165da8534 to your computer and use it in GitHub Desktop.

Select an option

Save joerodgers/25c8a85796f6e19a31d4fb9165da8534 to your computer and use it in GitHub Desktop.
Example script that deploys the SharePointSSOAppCustomizer SPFx solution to the tenant catalog and then adds an instance to a single SPO site
#requires -modules "PnP.PowerShell"
# example script for deploying the following to an spo site
# https://github.com/microsoft/CopilotStudioSamples/tree/main/SSOSamples/SharePointSSOAppCustomizer
# requires Sites.FullControl.All or SharePoint Administrators role
Connect-PnPOnline -Url "https://$env:CDX_TENANT.sharepoint.com/sites/Copilot-Studio-Agent" `
-ClientId $env:CDX_CLIENTID `
-Thumbprint $env:CDX_THUMBPRINT `
-Tenant $env:CDX_TENANTID
# check tenant app catalog for app package
$solutionPackage = Get-PnPApp -Scope Tenant | Where-Object -Property Title -eq "sidebar-agent-client-side-solution"
if( -not $solutionPackage )
{
# upload app package to tenant app catalog, publish/trust it and make it available to all sites
$solutionPackage = Add-PnPApp -Path "C:\_projects\SharePointSSOAppCustomizer\sharepoint\solution\sidebar-agent.sppkg" -Scope Tenant -Publish -Overwrite -SkipFeatureDeployment
if( -not $solutionPackage )
{
Write-Host "Solution package not added in tenant app catalog."
return
}
}
$clientSideComponentId = "4c6e29f2-7eee-4f9f-bbd2-20c8859d0ba2" # do not modify
# check for existing application customizer on the context site
$appCustomizer = Get-PnPApplicationCustomizer -ClientSideComponentId $clientSideComponentId
if( $appCustomizer )
{
Write-Host "Application Customizer is already registered for ClientSideComponentId: $clientSideComponentId"
return
}
# not found, add new instance w/ properties. Update these values for your environment
$clientSideComponentProperties = @{}
$clientSideComponentProperties.agentTitle = "Contoso Copilot Studio Agent"
$clientSideComponentProperties.appClientId = "b4228a12-0960-4617-b433-c5663e62e9bf"
$clientSideComponentProperties.tenantId = $env:CDX_TENANTID
$clientSideComponentProperties.directConnectUrl = "https://default100754a5793b47928f52e5911dc4c7.7c.environment.api.powerplatform.com/copilotstudio/dataverse-backed/authenticated/bots/cr81b_agent6_vaKv1X/conversations?api-version=2022-03-01-preview"
Add-PnPApplicationCustomizer -Title "Copilot Studio Agent Sidecar Application Customizer" `
-Description "Copilot Studio Agent Sidecar Application Customizer"`
-Scope "Web" `
-ClientSideComponentId $clientSideComponentId `
-ClientSideComponentProperties ($clientSideComponentProperties | ConvertTo-Json -Compress)
Get-PnPApplicationCustomizer -ClientSideComponentId $clientSideComponentId | FL * -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment