Skip to content

Commit

Permalink
Merge pull request #3142 from ganesh-sanap/set-pnplist-allowdeletion
Browse files Browse the repository at this point in the history
Added AllowDeletion parameter to Set-PnPList cmdlet
  • Loading branch information
gautamdsheth authored May 28, 2023
2 parents 8cd0c33 + 3eaa331 commit 1d6c99f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 15 additions & 1 deletion documentation/Set-PnPList.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Updates list settings
```powershell
Set-PnPList -Identity <ListPipeBind> [-EnableContentTypes <Boolean>] [-BreakRoleInheritance]
[-ResetRoleInheritance] [-CopyRoleAssignments] [-ClearSubScopes] [-Title <String>] [-Description <String>]
[-Hidden <Boolean>] [-ForceCheckout <Boolean>] [-ListExperience <ListExperience>]
[-Hidden <Boolean>] [-AllowDeletion <Boolean>] [-ForceCheckout <Boolean>] [-ListExperience <ListExperience>]
[-EnableAttachments <Boolean>] [-EnableFolderCreation <Boolean>] [-EnableVersioning <Boolean>]
[-EnableMinorVersions <Boolean>] [-MajorVersions <UInt32>] [-MinorVersions <UInt32>]
[-EnableModeration <Boolean>] [-DraftVersionVisibility <DraftVisibilityType>] [-ReadSecurity <ListReadSecurity>] [-WriteSecurity <ListWriteSecurity>]
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion src/Commands/Lists/SetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1d6c99f

Please sign in to comment.