SharePoint Alerts help users stay informed about changes in lists, libraries, and documents. With PnP PowerShell, administrators can manage alerts efficiently, including creating, retrieving, updating, and deleting alerts in bulk.
This guide covers:
- Understanding SharePoint Alerts
- Managing Alerts using PnP PowerShell
- Automating Alert Management in Bulk
Prerequisites
✅ Install PnP PowerShell
Install-Module -Name PnP.PowerShell -Force -AllowClobber
Connect to SharePoint Online
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com" -Interactive
Admin or Site Owner permissions
Step 1: Retrieve Existing Alerts
To list all alerts for the current user in a SharePoint site:
Get-PnPAlert
🔹 This returns all alerts created by the logged-in user.
To get alerts for a specific user:
Get-PnPAlert -User "user@domain.com"
Step 2: Create a New Alert
To create an alert for a user on a specific list or library:
New-PnPAlert -List "Documents" -User "user@domain.com" -Title "Document Updates" -DeliveryMethod Email -EventType All -Frequency Daily
Parameters:
-List→ Name of the SharePoint list or library-User→ Email of the user receiving the alert-Title→ Name of the alert-DeliveryMethod→EmailorSMS-EventType→All,AddObject,ModifyObject,DeleteObject-Frequency→Immediate,Daily,Weekly
This creates an alert for all document changes, sending a daily email update.
Step 3: Create Alerts in Bulk (CSV Method)
If you need to assign alerts to multiple users, create a CSV file (Alerts.csv) with:
| ListName | UserEmail | AlertTitle | Frequency |
|---|---|---|---|
| Documents | user1@domain.com | Document Updates | Daily |
| Tasks | user2@domain.com | Task Notifications | Weekly |
Run the Bulk Script
$alerts = Import-Csv -Path "C:\Alerts.csv"
foreach ($alert in $alerts) {
try {
New-PnPAlert -List $alert.ListName -User $alert.UserEmail -Title $alert.AlertTitle -DeliveryMethod Email -EventType All -Frequency $alert.Frequency
Write-Host "Alert '$($alert.AlertTitle)' created for $($alert.UserEmail)" -ForegroundColor Green
}
catch {
Write-Host "Failed to create alert for $($alert.UserEmail): $_" -ForegroundColor Red
}
}
Automates creating alerts for multiple users in different lists.
Step 4: Update an Existing Alert
To modify an existing alert:
Set-PnPAlert -Identity "Document Updates" -List "Documents" -Frequency Weekly
🔹 This changes the alert frequency to weekly.
Step 5: Delete Alerts
To remove a specific alert:
Remove-PnPAlert -Identity "Document Updates"
🔹 Deletes the “Document Updates” alert for the logged-in user.
To delete all alerts for a user:
Get-PnPAlert -User "user@domain.com" | Remove-PnPAlert
Removes all alerts assigned to a specific user.
Delete Alerts in Bulk (CSV Method)
Use a CSV file (RemoveAlerts.csv):
| UserEmail | ListName | AlertTitle |
|---|---|---|
| user1@domain.com | Documents | Document Updates |
| user2@domain.com | Tasks | Task Notifications |
Run the script:
$alertsToRemove = Import-Csv -Path "C:\RemoveAlerts.csv"
foreach ($alert in $alertsToRemove) {
try {
$userAlerts = Get-PnPAlert -User $alert.UserEmail | Where-Object { $_.Title -eq $alert.AlertTitle -and $_.List -eq $alert.ListName }
if ($userAlerts) {
$userAlerts | Remove-PnPAlert
Write-Host "Alert '$($alert.AlertTitle)' removed from $($alert.UserEmail)" -ForegroundColor Yellow
} else {
Write-Host "No matching alert found for $($alert.UserEmail)" -ForegroundColor Red
}
}
catch {
Write-Host "Error removing alert for $($alert.UserEmail): $_" -ForegroundColor Red
}
}
Deletes multiple alerts from different lists for different users.
Step 6: Automate with Task Scheduler
1️⃣ Open Task Scheduler
2️⃣ Click Create Basic Task
3️⃣ Set Trigger: Daily/Weekly
4️⃣ Set Action: Start a Program
5️⃣ In Program/script, enter:
-ExecutionPolicy Bypass -File "C:\YourScriptPath\ManageAlerts.ps1"
6️⃣ Click Finish
This automates alert creation, updates, or deletions at regular intervals.
Troubleshooting Common Issues
1. User Not Found Error
Ensure the user exists in SharePoint.
Check if the email format is correct.
2. Alert Not Found Error
Run Get-PnPAlert to list alerts and verify names.
3. Connection Issues
Ensure you are connected with Connect-PnPOnline.
Run scripts as an administrator.
