Skip to content

Commit dd75377

Browse files
committed
Import Kaspers Sample
1 parent 5ce6ab8 commit dd75377

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
plugin: add-to-gallery
3+
---
4+
5+
# Scan libraries for webhook and export to csv
6+
7+
## Summary
8+
9+
As part of the the pre migration assessment, it is important to identify all libraries that have webhooks configured. This script will scan all libraries in a site collection and export the libraries that have webhooks configured to a csv file.
10+
11+
![Example Screenshot](assets/example.png)
12+
13+
14+
# [PnP PowerShell](#tab/pnpps)
15+
16+
```powershell
17+
18+
19+
#use this function to get the sites you want to check
20+
function GetSitesToCheck
21+
{
22+
#$allsites = Get-PnPTenantSite -Connection $adminConn -Filter "Url -like 'https://contoso.sharepoint.com/'" -ErrorAction Stop
23+
$allsites = Get-PnPTenantSite -Connection $adminConn -ErrorAction Stop
24+
return $allsites
25+
}
26+
27+
28+
$adminUrl = "https://contoso-admin.sharepoint.com"
29+
$PnPClientId = "Your PnP Client ID"
30+
$adminConn = Connect-PnPOnline -Url $adminUrl -Interactive -ClientId $PnPClientId
31+
$outputPath = "C:\temp\"
32+
$sites = GetSitesToCheck
33+
$output = @()
34+
foreach ($site in $sites)
35+
{
36+
$siteUrl = $site.Url
37+
$siteConn = Connect-PnPOnline -Url $siteUrl -Interactive -ClientId $PnPClientId
38+
$libraries = Get-PnPList | Where-Object {$_.BaseType -eq "DocumentLibrary"}
39+
foreach ($library in $libraries)
40+
{
41+
$webhooks = Get-PnPWebhookSubscription -List $library.Title
42+
foreach ($webhook in $webhooks)
43+
{
44+
Write-Host "Library $($library.Title) in site $($site.Title) has $($webhooks.Count) webhooks"
45+
$output += [PSCustomObject]@{
46+
SiteUrl = $siteUrl
47+
SiteTitle = $site.Title
48+
LibraryTitle = $library.Title
49+
WebhookId = $webhook.Id
50+
WebhookExpirationDateTime = $webhook.ExpirationDateTime
51+
WebhookNotificationUrl = $webhook.NotificationUrl
52+
WebhookResource = $webhook.Resource
53+
WebhookClientState = $webhook.ClientState
54+
}
55+
}
56+
}
57+
}
58+
59+
$output | Export-Csv -Path "$outputPath\Webhooks.csv" -Encoding utf8BOM -Delimiter "|" -Force;
60+
61+
62+
```
63+
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
64+
***
65+
66+
67+
## Contributors
68+
69+
| Author(s) |
70+
|-----------|
71+
| Kasper Larsen |
72+
73+
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
74+
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-get-libraries-with-webhooks" aria-hidden="true" />
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[
2+
{
3+
"name": "spo-get-libraries-with-webhooks",
4+
"source": "pnp",
5+
"title": "Scan libraries for webhook and export to csv",
6+
"shortDescription": "Scanning document libraries and reporting on those that contains 1 or more webhooks",
7+
"url": "https://pnp.github.io/script-samples/spo-get-libraries-with-webhooks/README.html",
8+
"longDescription": [
9+
""
10+
],
11+
"creationDateTime": "2025-03-06",
12+
"updateDateTime": "2025-03-06",
13+
"products": [
14+
"SharePoint",
15+
"Azure"
16+
],
17+
"metadata": [
18+
{
19+
"key": "PNP-POWERSHELL",
20+
"value": "2.12.0"
21+
}
22+
],
23+
"categories": [
24+
"Deploy",
25+
"Provision",
26+
"Configure",
27+
"Report",
28+
"Security"
29+
],
30+
"tags": [
31+
"Get-PnPWebhookSubscription"
32+
],
33+
"thumbnails": [
34+
{
35+
"type": "image",
36+
"order": 100,
37+
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-get-libraries-with-webhooks/assets/preview.png",
38+
"alt": "Preview of the sample Scan libraries for webhook and export to csv"
39+
}
40+
],
41+
"authors": [
42+
{
43+
"gitHubAccount": "kasperbolarsen",
44+
"company": "",
45+
"pictureUrl": "https://github.com/kasperbolarsen.png",
46+
"name": "Kasper Larsen"
47+
}
48+
],
49+
"references": [
50+
{
51+
"name": "Want to learn more about PnP PowerShell and the cmdlets",
52+
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
53+
"url": "https://aka.ms/pnp/powershell"
54+
}
55+
]
56+
}
57+
]

0 commit comments

Comments
 (0)