|
| 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) |
0 commit comments