Skip to content

Commit ef19f07

Browse files
CopilotKoenZomers
andcommitted
Add SharePoint Rules cmdlets implementation
Co-authored-by: KoenZomers <5940670+KoenZomers@users.noreply.github.com>
1 parent cce8d39 commit ef19f07

File tree

16 files changed

+1532
-0
lines changed

16 files changed

+1532
-0
lines changed

documentation/Add-PnPListRule.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
schema: 2.0.0
4+
applicable: SharePoint Online
5+
online version: https://pnp.github.io/powershell/cmdlets/Add-PnPListRule.html
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
title: Add-PnPListRule
8+
---
9+
10+
# Add-PnPListRule
11+
12+
## SYNOPSIS
13+
Adds a new SharePoint list or library rule.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Add-PnPListRule -List <ListPipeBind> -Title <String> -TriggerEventType <String> -ActionType <String>
19+
[-Description <String>] [-EmailRecipients <String[]>] [-EmailSubject <String>] [-EmailBody <String>]
20+
[-Condition <String>] [-Enabled] [-Connection <PnPConnection>]
21+
```
22+
23+
## DESCRIPTION
24+
Adds a new rule to a SharePoint list or library. SharePoint Rules are the replacement for SharePoint Alerts which are being retired. Rules can trigger actions like sending email notifications when items are created, modified, or deleted.
25+
26+
## EXAMPLES
27+
28+
### EXAMPLE 1
29+
```powershell
30+
Add-PnPListRule -List "Demo List" -Title "Notify on new items" -TriggerEventType "create" -ActionType "sendEmail" -EmailRecipients "user@contoso.com"
31+
```
32+
33+
Creates a rule that sends an email to the specified recipient when a new item is created in the "Demo List".
34+
35+
### EXAMPLE 2
36+
```powershell
37+
Add-PnPListRule -List "Documents" -Title "Document modified alert" -TriggerEventType "update" -ActionType "sendEmail" -EmailRecipients "team@contoso.com" -EmailSubject "Document Updated" -EmailBody "A document has been modified in the library"
38+
```
39+
40+
Creates a rule that sends a custom email when a document is modified in the "Documents" library.
41+
42+
### EXAMPLE 3
43+
```powershell
44+
Add-PnPListRule -List "Tasks" -Title "Task deleted notification" -TriggerEventType "delete" -ActionType "sendEmail" -EmailRecipients "manager@contoso.com","admin@contoso.com" -Description "Notify managers when tasks are deleted"
45+
```
46+
47+
Creates a rule that notifies multiple recipients when a task is deleted, with a description for the rule.
48+
49+
## PARAMETERS
50+
51+
### -ActionType
52+
The type of action to perform when the rule is triggered (e.g., "sendEmail").
53+
54+
```yaml
55+
Type: String
56+
Parameter Sets: (All)
57+
58+
Required: True
59+
Position: Named
60+
Default value: None
61+
Accept pipeline input: False
62+
Accept wildcard characters: False
63+
```
64+
65+
### -Condition
66+
Optional condition that must be met for the rule to trigger.
67+
68+
```yaml
69+
Type: String
70+
Parameter Sets: (All)
71+
72+
Required: False
73+
Position: Named
74+
Default value: None
75+
Accept pipeline input: False
76+
Accept wildcard characters: False
77+
```
78+
79+
### -Connection
80+
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
81+
82+
```yaml
83+
Type: PnPConnection
84+
Parameter Sets: (All)
85+
86+
Required: False
87+
Position: Named
88+
Default value: None
89+
Accept pipeline input: False
90+
Accept wildcard characters: False
91+
```
92+
93+
### -Description
94+
Optional description for the rule.
95+
96+
```yaml
97+
Type: String
98+
Parameter Sets: (All)
99+
100+
Required: False
101+
Position: Named
102+
Default value: None
103+
Accept pipeline input: False
104+
Accept wildcard characters: False
105+
```
106+
107+
### -EmailBody
108+
The body content for email notifications.
109+
110+
```yaml
111+
Type: String
112+
Parameter Sets: (All)
113+
114+
Required: False
115+
Position: Named
116+
Default value: None
117+
Accept pipeline input: False
118+
Accept wildcard characters: False
119+
```
120+
121+
### -EmailRecipients
122+
The email addresses to send notifications to.
123+
124+
```yaml
125+
Type: String[]
126+
Parameter Sets: (All)
127+
128+
Required: False
129+
Position: Named
130+
Default value: None
131+
Accept pipeline input: False
132+
Accept wildcard characters: False
133+
```
134+
135+
### -EmailSubject
136+
The subject line for email notifications.
137+
138+
```yaml
139+
Type: String
140+
Parameter Sets: (All)
141+
142+
Required: False
143+
Position: Named
144+
Default value: None
145+
Accept pipeline input: False
146+
Accept wildcard characters: False
147+
```
148+
149+
### -Enabled
150+
Whether the rule is enabled. Enabled by default.
151+
152+
```yaml
153+
Type: SwitchParameter
154+
Parameter Sets: (All)
155+
156+
Required: False
157+
Position: Named
158+
Default value: True
159+
Accept pipeline input: False
160+
Accept wildcard characters: False
161+
```
162+
163+
### -List
164+
The ID, Title or Url of the list.
165+
166+
```yaml
167+
Type: ListPipeBind
168+
Parameter Sets: (All)
169+
170+
Required: True
171+
Position: 0
172+
Default value: None
173+
Accept pipeline input: True (ByValue)
174+
Accept wildcard characters: False
175+
```
176+
177+
### -Title
178+
The title/name of the rule.
179+
180+
```yaml
181+
Type: String
182+
Parameter Sets: (All)
183+
184+
Required: True
185+
Position: Named
186+
Default value: None
187+
Accept pipeline input: False
188+
Accept wildcard characters: False
189+
```
190+
191+
### -TriggerEventType
192+
The type of event that triggers the rule (e.g., "create", "update", "delete").
193+
194+
```yaml
195+
Type: String
196+
Parameter Sets: (All)
197+
198+
Required: True
199+
Position: Named
200+
Default value: None
201+
Accept pipeline input: False
202+
Accept wildcard characters: False
203+
```
204+
205+
## RELATED LINKS
206+
207+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
208+
[SharePoint Alerts Retirement](https://support.microsoft.com/en-us/office/sharepoint-alerts-retirement-813a90c7-3ff1-47a9-8a2f-152f48b2486f)

documentation/Get-PnPListRule.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
schema: 2.0.0
4+
applicable: SharePoint Online
5+
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPListRule.html
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
title: Get-PnPListRule
8+
---
9+
10+
# Get-PnPListRule
11+
12+
## SYNOPSIS
13+
Retrieves SharePoint list or library rules.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Get-PnPListRule -List <ListPipeBind> [-Identity <RulePipeBind>] [-Connection <PnPConnection>]
19+
```
20+
21+
## DESCRIPTION
22+
Retrieves all rules or a specific rule from a SharePoint list or library. SharePoint Rules are the replacement for SharePoint Alerts which are being retired.
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```powershell
28+
Get-PnPListRule -List "Demo List"
29+
```
30+
31+
Returns all rules configured on the "Demo List".
32+
33+
### EXAMPLE 2
34+
```powershell
35+
Get-PnPListRule -List "Demo List" -Identity "12345678-1234-1234-1234-123456789012"
36+
```
37+
38+
Returns the rule with the specified ID from the "Demo List".
39+
40+
### EXAMPLE 3
41+
```powershell
42+
Get-PnPListRule -List "Demo List" -Identity "My Rule"
43+
```
44+
45+
Returns rules with the title "My Rule" from the "Demo List".
46+
47+
## PARAMETERS
48+
49+
### -Connection
50+
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
51+
52+
```yaml
53+
Type: PnPConnection
54+
Parameter Sets: (All)
55+
56+
Required: False
57+
Position: Named
58+
Default value: None
59+
Accept pipeline input: False
60+
Accept wildcard characters: False
61+
```
62+
63+
### -Identity
64+
The ID or Title of the rule to retrieve. If not specified, all rules for the list will be returned.
65+
66+
```yaml
67+
Type: RulePipeBind
68+
Parameter Sets: (All)
69+
70+
Required: False
71+
Position: Named
72+
Default value: None
73+
Accept pipeline input: False
74+
Accept wildcard characters: False
75+
```
76+
77+
### -List
78+
The ID, Title or Url of the list.
79+
80+
```yaml
81+
Type: ListPipeBind
82+
Parameter Sets: (All)
83+
84+
Required: True
85+
Position: 0
86+
Default value: None
87+
Accept pipeline input: True (ByValue)
88+
Accept wildcard characters: False
89+
```
90+
91+
## RELATED LINKS
92+
93+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
94+
[SharePoint Alerts Retirement](https://support.microsoft.com/en-us/office/sharepoint-alerts-retirement-813a90c7-3ff1-47a9-8a2f-152f48b2486f)

0 commit comments

Comments
 (0)