Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 17, 2025

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

  • Create Model classes for SharePoint Rules

    • Create Rule.cs model class with all properties
    • Create RuleAction.cs for rule actions
    • Create RuleTrigger.cs for rule triggers
    • Create RulePipeBind.cs for flexible input
  • Create Core Cmdlets

    • Get-PnPListRule - Retrieve rules for a list
    • Add-PnPListRule - Create a new rule
    • Set-PnPListRule - Update an existing rule
    • Remove-PnPListRule - Delete a rule
  • Add Documentation

    • Create Get-PnPListRule.md
    • Create Add-PnPListRule.md
    • Create Set-PnPListRule.md
    • Create Remove-PnPListRule.md
  • Add Tests

    • Create GetPnPListRuleTests.cs
    • Create AddPnPListRuleTests.cs
    • Create SetPnPListRuleTests.cs
    • Create RemovePnPListRuleTests.cs
  • Build and Validate

    • Ensure code builds successfully (0 warnings, 0 errors)
    • Code review completed with no issues
    • Changelog entry added

Summary of Changes

New Cmdlets Added:

  1. Get-PnPListRule - Retrieves SharePoint list or library rules

    • Supports filtering by rule ID or title
    • Returns all rules if no identity specified
  2. Add-PnPListRule - Creates a new rule

    • Requires: List, Title, TriggerEventType, ActionType
    • Optional: Description, EmailRecipients, EmailSubject, EmailBody, Condition, Enabled
  3. Set-PnPListRule - Updates an existing rule

    • Only updates specified parameters
    • Supports partial updates
  4. 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 to web/lists(guid'{listId}')/GetAllRules
  • CreateRuleEx - POST to web/lists(guid'{listId}')/CreateRuleEx
  • UpdateRule - POST to web/lists(guid'{listId}')/UpdateRule
  • DeleteRule - POST to web/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

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 @kbeeveer46

Well 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/Guid

and 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 #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.

Co-authored-by: KoenZomers <5940670+KoenZomers@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add cmdlets for SharePoint Rules in PnP PowerShell Add SharePoint Rules cmdlets as replacement for retiring SharePoint Alerts Oct 17, 2025
@Copilot Copilot AI requested a review from KoenZomers October 17, 2025 11:43
Copilot finished work on behalf of KoenZomers October 17, 2025 11:43
@KoenZomers
Copy link
Collaborator

@copilot Please add a changelog entry to Changelog.md as well referencing this PR #5123

Co-authored-by: KoenZomers <5940670+KoenZomers@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 17, 2025

@copilot Please add a changelog entry to Changelog.md as well referencing this PR #5123

Added changelog entry in commit ef19f07.

Copilot finished work on behalf of KoenZomers October 17, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] SharePoint Alerts is being retired. Will PnP PowerShell support SharePoint Rules which is now the recommended method?

2 participants