Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AllowDeletion parameter to Set-PnPList cmdlet #3142

Merged
merged 1 commit into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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