Add SharePoint Rules cmdlets as replacement for retiring SharePoint Alerts
SharePoint Rules Implementation - COMPLETE ✅
This PR implements cmdlets for SharePoint Rules, which is the replacement for SharePoint Alerts that are being retired in 2025.
Implementation Checklist
-
[x] Create Model classes for SharePoint Rules
- [x] Create Rule.cs model class with all properties
- [x] Create RuleAction.cs for rule actions
- [x] Create RuleTrigger.cs for rule triggers
- [x] Create RulePipeBind.cs for flexible input
-
[x] Create Core Cmdlets
- [x] Get-PnPListRule - Retrieve rules for a list
- [x] Add-PnPListRule - Create a new rule
- [x] Set-PnPListRule - Update an existing rule
- [x] Remove-PnPListRule - Delete a rule
-
[x] Add Documentation
- [x] Create Get-PnPListRule.md
- [x] Create Add-PnPListRule.md
- [x] Create Set-PnPListRule.md
- [x] Create Remove-PnPListRule.md
-
[x] Add Tests
- [x] Create GetPnPListRuleTests.cs
- [x] Create AddPnPListRuleTests.cs
- [x] Create SetPnPListRuleTests.cs
- [x] Create RemovePnPListRuleTests.cs
-
[x] Build and Validate
- [x] Ensure code builds successfully (0 warnings, 0 errors)
- [x] Code review completed with no issues
- [x] Changelog entry added
Summary of Changes
New Cmdlets Added:
-
Get-PnPListRule - Retrieves SharePoint list or library rules
- Supports filtering by rule ID or title
- Returns all rules if no identity specified
-
Add-PnPListRule - Creates a new rule
- Requires: List, Title, TriggerEventType, ActionType
- Optional: Description, EmailRecipients, EmailSubject, EmailBody, Condition, Enabled
-
Set-PnPListRule - Updates an existing rule
- Only updates specified parameters
- Supports partial updates
-
Remove-PnPListRule - Deletes a rule
- Includes confirmation prompt (can be bypassed with -Force)
Model Classes:
-
Rule- Main rule entity with RuleId, Title, Description, IsEnabled, TriggerCondition, ActionParameters, timestamps -
RuleTrigger- Event type, condition, field values -
RuleAction- Action type, email recipients, subject, body, additional parameters -
RulePipeBind- Flexible input accepting Rule ID (Guid), Title (string), or Rule object
SharePoint REST API Integration:
-
GetAllRules- POST toweb/lists(guid'{listId}')/GetAllRules -
CreateRuleEx- POST toweb/lists(guid'{listId}')/CreateRuleEx -
UpdateRule- POST toweb/lists(guid'{listId}')/UpdateRule -
DeleteRule- POST toweb/lists(guid'{listId}')/DeleteRule
Code Quality
✅ Build successful (0 warnings, 0 errors) ✅ Follows PnP PowerShell coding conventions (tabs, naming, patterns) ✅ Proper error handling with meaningful messages ✅ Pipeline support via ListPipeBind and RulePipeBind ✅ Comprehensive documentation with practical examples ✅ Test scaffolding following existing patterns ✅ Code review passed with no issues ✅ Changelog entry added referencing PR #5123
Migration Path for Users
Users can now migrate from the retiring SharePoint Alerts to SharePoint Rules:
- Alert functionality:
Get/Add/Remove-PnPAlert→ Rule functionality:Get/Add/Set/Remove-PnPListRule - Rules provide more flexibility and modern automation capabilities
- Documentation references the SharePoint Alerts retirement announcement
Files Changed (17 files)
Source Code (8 files):
- src/Commands/Rules/GetListRule.cs
- src/Commands/Rules/AddListRule.cs
- src/Commands/Rules/SetListRule.cs
- src/Commands/Rules/RemoveListRule.cs
- src/Commands/Model/SharePoint/Rule.cs
- src/Commands/Model/SharePoint/RuleAction.cs
- src/Commands/Model/SharePoint/RuleTrigger.cs
- src/Commands/Base/PipeBinds/RulePipeBind.cs
Documentation (4 files):
- documentation/Get-PnPListRule.md
- documentation/Add-PnPListRule.md
- documentation/Set-PnPListRule.md
- documentation/Remove-PnPListRule.md
Tests (4 files):
- src/Tests/Rules/GetPnPListRuleTests.cs
- src/Tests/Rules/AddPnPListRuleTests.cs
- src/Tests/Rules/SetPnPListRuleTests.cs
- src/Tests/Rules/RemovePnPListRuleTests.cs
Changelog (1 file):
- CHANGELOG.md
Related Links
- SharePoint Alerts Retirement Announcement
- GitHub Issue: [FEATURE] SharePoint Alerts is being retired. Will PnP PowerShell support SharePoint Rules?
Original prompt
This section details on the original issue you should resolve
<issue_title>[FEATURE] SharePoint Alerts is being retired. Will PnP PowerShell support SharePoint Rules which is now the recommended method?</issue_title> <issue_description>See the following article for the retirement dates. Are there plans to add cmdlets for SharePoint Rules? Are there any other PowerShell or JavaScript libraries that lets you create rules?
https://support.microsoft.com/en-us/office/sharepoint-alerts-retirement-813a90c7-3ff1-47a9-8a2f-152f48b2486f
</issue_description>
Comments on the Issue (you are @copilot in this section)
@NishkalankBezawada Hello @kbeeveer46Well we have below API to get the alerts
GET https://contoso.sharepoint.com/sites/Marketing/_api/Web/Alerts?$expand=List,User,List/Rootfolder,Item&$select=*,List/Id,List/Title,List/Rootfolder/ServerRelativeUrl,Item/ID,Item/FileRef,Item/Guidand Also, below API to delete the alert based on the alert ID
DELETE https://contoso.sharepoint.com/sites/Marketing/_api/Web/Alerts/DeleteAlert('<alert ID>')Considering that the fact SharePoint Online list alerts are retired and will stop working next year (announcement). I think its good to have this feature to be supported.
Your insights please @erwinvanhunen @gautamdsheth @KoenZomers @reshmee011
Thanks, Nish</comment_new>
Fixes pnp/powershell#5039
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot Please add a changelog entry to Changelog.md as well referencing this PR #5123
@copilot Please add a changelog entry to Changelog.md as well referencing this PR #5123
Added changelog entry in commit ef19f07.