Skip to content

Commit 695ee81

Browse files
authored
Merge pull request #781 from kasperbolarsen/main
sample exporting data from MS Search externalItems
2 parents 395fe01 + d35ca28 commit 695ee81

File tree

8 files changed

+126
-232
lines changed

8 files changed

+126
-232
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
plugin: add-to-gallery
3+
---
4+
5+
# Export data from MS Search
6+
7+
8+
## Summary
9+
10+
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.
11+
12+
![Example Screenshot](assets/example.png)
13+
14+
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
15+
Finally you have to provide the name of the external data source (you can get this from the Search And Intelligence Admin Center)
16+
17+
18+
# [PnP PowerShell](#tab/pnpps)
19+
20+
```powershell
21+
22+
$clientId = "aaaaaa-11111-222222-bbbbb-44444444"
23+
$portalConn = Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive -ClientId $clientId -ReturnConnection
24+
25+
$content = @{
26+
"Requests" = @(
27+
@{
28+
"entityTypes" = @(
29+
"externalItem"
30+
)
31+
"query" = @{
32+
"queryString" = "*"
33+
}
34+
"contentSources" = @(
35+
"/external/connections/AzureSqlConnector3"
36+
)
37+
"fields"= @(
38+
"CustomerName",
39+
"CustomerArea",
40+
"LocationID",
41+
"LocationName",
42+
"Responsible"
43+
)
44+
}
45+
)
46+
}
47+
48+
#converting the content to json in order to use it in the Graph Explorer, which is a great way to test the queries
49+
$json = $content | ConvertTo-Json -Depth 10
50+
$res = Invoke-PnPGraphMethod -Url "/v1.0/search/query" -Method Post -Content $content -Connection $portalConn
51+
52+
53+
$hits = $res.value.hitsContainers.hits
54+
foreach($hit in $hits)
55+
{
56+
$hit.resource.properties
57+
#do something with the data, like exporting it to a csv file
58+
}
59+
60+
```
61+
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
62+
***
63+
64+
65+
## Contributors
66+
67+
| Author(s) |
68+
|-----------|
69+
| Kasper Larsen |
70+
71+
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
72+
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/export-data-from-microsoft-search" aria-hidden="true" />
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[
2+
{
3+
"name": "export-data-from-microsoft-search",
4+
"source": "pnp",
5+
"title": "Export data from MS Search",
6+
"shortDescription": "Shows how to export data from MS Search, in this case the entityType externalItem ",
7+
"url": "https://pnp.github.io/script-samples/export-data-from-microsoft-search/README.html",
8+
"longDescription": [
9+
""
10+
],
11+
"creationDateTime": "2024-11-11",
12+
"updateDateTime": "2024-11-11",
13+
"products": [
14+
"Graph",
15+
"Microsoft Search"
16+
],
17+
"metadata": [
18+
{
19+
"key": "PNP-POWERSHELL",
20+
"value": "2.12.0"
21+
}
22+
],
23+
"categories": [
24+
"Data",
25+
"Report"
26+
],
27+
"tags": [
28+
"Invoke-PnPGraphMethod"
29+
],
30+
"thumbnails": [
31+
{
32+
"type": "image",
33+
"order": 100,
34+
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/export-data-from-microsoft-search/assets/preview.png",
35+
"alt": "Preview of the sample Export data from MS Search"
36+
}
37+
],
38+
"authors": [
39+
{
40+
"gitHubAccount": "kasperbolarsen",
41+
"company": "",
42+
"pictureUrl": "https://github.com/kasperbolarsen.png",
43+
"name": "Kasper Larsen"
44+
}
45+
],
46+
"references": [
47+
{
48+
"name": "Want to learn more about PnP PowerShell and the cmdlets",
49+
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
50+
"url": "https://aka.ms/pnp/powershell"
51+
}
52+
]
53+
}
54+
]

scripts/spo-apply-custom-form-formatting-json/README.md

-177
This file was deleted.
Binary file not shown.
Binary file not shown.

scripts/spo-apply-custom-form-formatting-json/assets/sample.json

-55
This file was deleted.

0 commit comments

Comments
 (0)