Skip to content

Instantly share code, notes, and snippets.

@vman
Last active December 18, 2025 04:07
Show Gist options
  • Select an option

  • Save vman/fcf60982ad1db4e53c9b985d498adff7 to your computer and use it in GitHub Desktop.

Select an option

Save vman/fcf60982ad1db4e53c9b985d498adff7 to your computer and use it in GitHub Desktop.
# Delegated token for the signed-in user with Files.Read.All + Sites.Read.All
$token = "<ACCESS_TOKEN>"
$body = @{
queryString = "What is our paternal leave policy?"
dataSource = "sharePoint"
filterExpression = 'path:"https://contoso.sharepoint.com/sites/HR1/"'
resourceMetadata = @("title","author")
maximumNumberOfResults = 4
} | ConvertTo-Json -Depth 6
Invoke-RestMethod -Method Post `
-Uri "https://graph.microsoft.com/v1.0/copilot/retrieval" `
-Headers @{ Authorization = "Bearer $token"; "Content-Type" = "application/json" } `
-Body $body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment