Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created July 20, 2023 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderHolmeset/d109f3532c0a60e9f97cc1c1266197c7 to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/d109f3532c0a60e9f97cc1c1266197c7 to your computer and use it in GitHub Desktop.
$AzureCognitiveSearchURL = "https://sharepointsearchinstance.search.windows.net"
$AzureCognitiveSearchAdminKey = "Wt1mZ0sjkKoXW913d2eJ8xXYJk4JHThk1UK8H0wZoIAzSeDjYTmC"
$SharePointSiteURL = "https://alexholmeset.sharepoint.com/sites/TestDemoTeam/"
$AzureAppregistrationID = "861eade5-bb96-41cc-af4b-55dce97b020e"
$AzureAppregistrationSecret = "8re8Q~pR6icm6oT5Fx8UwiDO~xgoeYp~8KGiXaF3"
$TenantID = "29594fb0-53f2-490c-a1be-8b2cca824805"
$Header = @{"api-key" = "$AzureCognitiveSearchAdminKey"
"content-type" = "application/json"
}
$Body = @"
{
"name" : "sharepoint-datasource",
"type" : "sharepoint",
"credentials" : { "connectionString" : "SharePointOnlineEndpoint=$SharePointSiteURL;ApplicationId=$AzureAppregistrationID;ApplicationSecret=$AzureAppregistrationSecret;TenantId=$TenantID" },
"container" : { "name" : "defaultSiteLibrary", "query" : null }
}
"@
$uri = "$AzureCognitiveSearchURL/datasources?api-version=2020-06-30-Preview"
invoke-restmethod -Method POST -Uri $uri -Body $body -Headers $Header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment