New sample script: SharePoint Online list alerts retirement report.#7001
New sample script: SharePoint Online list alerts retirement report.#7001milanholemans merged 3 commits intopnp:mainfrom
Conversation
|
Thanks @Saurabh7019! We'll try to review it ASAP! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new sample script to help administrators generate reports on SharePoint Online list alerts across their tenant in preparation for the retirement of this feature. The script provides a comprehensive PowerShell solution to scan all sites and export alert information to CSV format.
Key Changes
- Adds a PowerShell script that scans all tenant sites for existing SharePoint alerts
- Generates a detailed CSV report with alert metadata including frequency, users, and target paths
- Includes proper metadata and documentation for the sample script
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docs/docs/sample-scripts/spo/list-tenant-alert-usage/index.mdx | Main documentation page with PowerShell script for generating tenant-wide alert reports |
| docs/docs/sample-scripts/spo/list-tenant-alert-usage/assets/sample.json | Metadata configuration for the sample script including author info, tags, and references |
milanholemans
left a comment
There was a problem hiding this comment.
Script looks really nice @Saurabh7019! I made a few suggestions to make it good to go.
Thanks for the effort!
5fd67c8 to
526ca5f
Compare
milanholemans
left a comment
There was a problem hiding this comment.
Nice improvements so far, I think still think we have to improve it a little bit further.
Let me know if anything is unclear.
526ca5f to
f662e1a
Compare
|
Thank you for great feedback, @milanholemans. I have made the requested changes, can you have another look when you have time? |
milanholemans
left a comment
There was a problem hiding this comment.
Awesome, looks good to go with a few tiny tweaks!
| ```powershell | ||
| $fileExportPath = "Alerts.csv" | ||
|
|
||
| function Get-AlertsToResults { |
There was a problem hiding this comment.
Thinking of it some more, I think the verb Convert fits better here.
| function Get-AlertsToResults { | |
| function Convert-AlertsToResults { |
|
|
||
| try { | ||
| # Get deprecated alerts from specific site | ||
| $alerts = m365 spo web alert list --webUrl $SiteUrl --output json --query "[?!(Properties[].Key && contains(Properties[].Key, 'ruletitle'))]" | ConvertFrom-Json |
There was a problem hiding this comment.
Nice use of the query parameter, awesome!
| $sites = m365 spo site list --output json | ConvertFrom-Json | ||
| $sites = $sites | Where-Object { $_.ArchiveStatus -eq "NotArchived" } |
There was a problem hiding this comment.
While this works, I think we can use the query parameter here as well quite easily. This makes it a bit more consistent with the code above.
| $webs = m365 spo web list --url $SiteUrl --output json | ConvertFrom-Json | ||
| foreach ($web in $webs) { | ||
| Write-Host "`tScanning subsite '$($web.Url)'..." -ForegroundColor Gray | ||
| $results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $SiteTitle |
There was a problem hiding this comment.
Currently, we're always passing the title of the site collection to all its subsites.
| $results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $SiteTitle | |
| $results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $web.Title |
Closes #6864