From 3eaa331676fbfe2e1ec0caa4b8bba44a3ff53d16 Mon Sep 17 00:00:00 2001 From: Ganesh Sanap Date: Sun, 28 May 2023 13:18:39 +0530 Subject: [PATCH] Added AllowDeletion parameter to Set-PnPList cmdlet --- documentation/Set-PnPList.md | 16 +++++++++++++++- src/Commands/Lists/SetList.cs | 11 ++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/documentation/Set-PnPList.md b/documentation/Set-PnPList.md index 56e5d9c29..f04971a3f 100644 --- a/documentation/Set-PnPList.md +++ b/documentation/Set-PnPList.md @@ -17,7 +17,7 @@ Updates list settings ```powershell Set-PnPList -Identity [-EnableContentTypes ] [-BreakRoleInheritance] [-ResetRoleInheritance] [-CopyRoleAssignments] [-ClearSubScopes] [-Title ] [-Description ] - [-Hidden ] [-ForceCheckout ] [-ListExperience ] + [-Hidden ] [-AllowDeletion ] [-ForceCheckout ] [-ListExperience ] [-EnableAttachments ] [-EnableFolderCreation ] [-EnableVersioning ] [-EnableMinorVersions ] [-MajorVersions ] [-MinorVersions ] [-EnableModeration ] [-DraftVersionVisibility ] [-ReadSecurity ] [-WriteSecurity ] @@ -334,6 +334,20 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -AllowDeletion +Allow or prevent deletion of the list from the SharePoint UI. Set to $true to allow, $false to prevent. + +```yaml +Type: Boolean +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Identity The ID, Title or Url of the list. diff --git a/src/Commands/Lists/SetList.cs b/src/Commands/Lists/SetList.cs index d7b0541a3..641fa5d92 100644 --- a/src/Commands/Lists/SetList.cs +++ b/src/Commands/Lists/SetList.cs @@ -38,6 +38,9 @@ public class SetList : PnPWebCmdlet [Parameter(Mandatory = false)] public bool Hidden; + [Parameter(Mandatory = false)] + public bool AllowDeletion; + [Parameter(Mandatory = false)] public bool ForceCheckout; @@ -122,7 +125,7 @@ protected override void ExecuteCmdlet() list = newIdentity.GetList(CurrentWeb); } - 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); + 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); var enableVersioning = list.EnableVersioning; var enableMinorVersions = list.EnableMinorVersions; @@ -152,6 +155,12 @@ protected override void ExecuteCmdlet() updateRequired = true; } + if (ParameterSpecified(nameof(AllowDeletion)) && AllowDeletion != list.AllowDeletion) + { + list.AllowDeletion = AllowDeletion; + updateRequired = true; + } + if (ParameterSpecified(nameof(EnableContentTypes)) && list.ContentTypesEnabled != EnableContentTypes) { list.ContentTypesEnabled = EnableContentTypes;