Skip to content

Commit

Permalink
Merge pull request #781 from kasperbolarsen/main
Browse files Browse the repository at this point in the history
sample exporting data from MS Search externalItems
  • Loading branch information
pkbullock authored Nov 12, 2024
2 parents 395fe01 + d35ca28 commit 695ee81
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 232 deletions.
72 changes: 72 additions & 0 deletions scripts/export-data-from-microsoft-search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
plugin: add-to-gallery
---

# Export data from MS Search


## Summary

When working with data imported into the Microsoft Search service using Graph Connectors, it can be useful to export the data to a format of your choice for further analysis or to import it into another system.

![Example Screenshot](assets/example.png)

You will have to connect just as usual, then you must specify the entity type you want , the fields (if you don't know the names of the fields, you can look in the Search And Intelligence Admin Center) or export the schema using Get-PnPSearchExternalSchema
Finally you have to provide the name of the external data source (you can get this from the Search And Intelligence Admin Center)


# [PnP PowerShell](#tab/pnpps)

```powershell
$clientId = "aaaaaa-11111-222222-bbbbb-44444444"
$portalConn = Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive -ClientId $clientId -ReturnConnection
$content = @{
"Requests" = @(
@{
"entityTypes" = @(
"externalItem"
)
"query" = @{
"queryString" = "*"
}
"contentSources" = @(
"/external/connections/AzureSqlConnector3"
)
"fields"= @(
"CustomerName",
"CustomerArea",
"LocationID",
"LocationName",
"Responsible"
)
}
)
}
#converting the content to json in order to use it in the Graph Explorer, which is a great way to test the queries
$json = $content | ConvertTo-Json -Depth 10
$res = Invoke-PnPGraphMethod -Url "/v1.0/search/query" -Method Post -Content $content -Connection $portalConn
$hits = $res.value.hitsContainers.hits
foreach($hit in $hits)
{
$hit.resource.properties
#do something with the data, like exporting it to a csv file
}
```
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
***


## Contributors

| Author(s) |
|-----------|
| Kasper Larsen |

[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/export-data-from-microsoft-search" aria-hidden="true" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions scripts/export-data-from-microsoft-search/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "export-data-from-microsoft-search",
"source": "pnp",
"title": "Export data from MS Search",
"shortDescription": "Shows how to export data from MS Search, in this case the entityType externalItem ",
"url": "https://pnp.github.io/script-samples/export-data-from-microsoft-search/README.html",
"longDescription": [
""
],
"creationDateTime": "2024-11-11",
"updateDateTime": "2024-11-11",
"products": [
"Graph",
"Microsoft Search"
],
"metadata": [
{
"key": "PNP-POWERSHELL",
"value": "2.12.0"
}
],
"categories": [
"Data",
"Report"
],
"tags": [
"Invoke-PnPGraphMethod"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/export-data-from-microsoft-search/assets/preview.png",
"alt": "Preview of the sample Export data from MS Search"
}
],
"authors": [
{
"gitHubAccount": "kasperbolarsen",
"company": "",
"pictureUrl": "https://github.com/kasperbolarsen.png",
"name": "Kasper Larsen"
}
],
"references": [
{
"name": "Want to learn more about PnP PowerShell and the cmdlets",
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
"url": "https://aka.ms/pnp/powershell"
}
]
}
]
177 changes: 0 additions & 177 deletions scripts/spo-apply-custom-form-formatting-json/README.md

This file was deleted.

Binary file not shown.
Binary file not shown.
55 changes: 0 additions & 55 deletions scripts/spo-apply-custom-form-formatting-json/assets/sample.json

This file was deleted.

0 comments on commit 695ee81

Please sign in to comment.