Skip to content

Commit 1d6c99f

Browse files
authored
Merge pull request #3142 from ganesh-sanap/set-pnplist-allowdeletion
Added AllowDeletion parameter to Set-PnPList cmdlet
2 parents 8cd0c33 + 3eaa331 commit 1d6c99f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

documentation/Set-PnPList.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Updates list settings
1717
```powershell
1818
Set-PnPList -Identity <ListPipeBind> [-EnableContentTypes <Boolean>] [-BreakRoleInheritance]
1919
[-ResetRoleInheritance] [-CopyRoleAssignments] [-ClearSubScopes] [-Title <String>] [-Description <String>]
20-
[-Hidden <Boolean>] [-ForceCheckout <Boolean>] [-ListExperience <ListExperience>]
20+
[-Hidden <Boolean>] [-AllowDeletion <Boolean>] [-ForceCheckout <Boolean>] [-ListExperience <ListExperience>]
2121
[-EnableAttachments <Boolean>] [-EnableFolderCreation <Boolean>] [-EnableVersioning <Boolean>]
2222
[-EnableMinorVersions <Boolean>] [-MajorVersions <UInt32>] [-MinorVersions <UInt32>]
2323
[-EnableModeration <Boolean>] [-DraftVersionVisibility <DraftVisibilityType>] [-ReadSecurity <ListReadSecurity>] [-WriteSecurity <ListWriteSecurity>]
@@ -334,6 +334,20 @@ Accept pipeline input: False
334334
Accept wildcard characters: False
335335
```
336336
337+
### -AllowDeletion
338+
Allow or prevent deletion of the list from the SharePoint UI. Set to $true to allow, $false to prevent.
339+
340+
```yaml
341+
Type: Boolean
342+
Parameter Sets: (All)
343+
344+
Required: False
345+
Position: Named
346+
Default value: None
347+
Accept pipeline input: False
348+
Accept wildcard characters: False
349+
```
350+
337351
### -Identity
338352
The ID, Title or Url of the list.
339353

src/Commands/Lists/SetList.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class SetList : PnPWebCmdlet
3838
[Parameter(Mandatory = false)]
3939
public bool Hidden;
4040

41+
[Parameter(Mandatory = false)]
42+
public bool AllowDeletion;
43+
4144
[Parameter(Mandatory = false)]
4245
public bool ForceCheckout;
4346

@@ -122,7 +125,7 @@ protected override void ExecuteCmdlet()
122125
list = newIdentity.GetList(CurrentWeb);
123126
}
124127

125-
list.EnsureProperties(l => l.EnableAttachments, l => l.EnableVersioning, l => l.EnableMinorVersions, l => l.Hidden, l => l.EnableModeration, l => l.BaseType, l => l.HasUniqueRoleAssignments, l => l.ContentTypesEnabled, l => l.ExemptFromBlockDownloadOfNonViewableFiles, l => l.DisableGridEditing, l => l.DisableCommenting);
128+
list.EnsureProperties(l => l.EnableAttachments, l => l.EnableVersioning, l => l.EnableMinorVersions, l => l.Hidden, l => l.AllowDeletion, l => l.EnableModeration, l => l.BaseType, l => l.HasUniqueRoleAssignments, l => l.ContentTypesEnabled, l => l.ExemptFromBlockDownloadOfNonViewableFiles, l => l.DisableGridEditing, l => l.DisableCommenting);
126129

127130
var enableVersioning = list.EnableVersioning;
128131
var enableMinorVersions = list.EnableMinorVersions;
@@ -152,6 +155,12 @@ protected override void ExecuteCmdlet()
152155
updateRequired = true;
153156
}
154157

158+
if (ParameterSpecified(nameof(AllowDeletion)) && AllowDeletion != list.AllowDeletion)
159+
{
160+
list.AllowDeletion = AllowDeletion;
161+
updateRequired = true;
162+
}
163+
155164
if (ParameterSpecified(nameof(EnableContentTypes)) && list.ContentTypesEnabled != EnableContentTypes)
156165
{
157166
list.ContentTypesEnabled = EnableContentTypes;

0 commit comments

Comments
 (0)