Skip to content

Commit

Permalink
Merge pull request #2778 from lilealdai/supportLargeListDelete
Browse files Browse the repository at this point in the history
Add support for large list recycle for Remove-PnPList
  • Loading branch information
gautamdsheth committed Feb 8, 2023
2 parents 2f4c87d + 1e5441b commit d05347d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
24 changes: 23 additions & 1 deletion documentation/Remove-PnPList.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Deletes a list.
## SYNTAX

```powershell
Remove-PnPList [-Identity] <ListPipeBind> [-Recycle] [-Force] [-Connection <PnPConnection>]
Remove-PnPList [-Identity] <ListPipeBind> [-Recycle] [-LargeList] [-Force] [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand Down Expand Up @@ -45,6 +45,14 @@ Remove-PnPList -Identity Announcements -Recycle

Removes the list named 'Announcements' and moves it to the Recycle Bin.

### EXAMPLE 4
```powershell
Remove-PnPList -Identity Announcements -Recycle -LargeList
```

Removes the large list named 'Announcements' and moves it to the Recycle Bin.


## PARAMETERS

### -Connection
Expand Down Expand Up @@ -103,6 +111,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -LargeList
When provided, the large list will be moved to recycle bin through a timer job. It must be paired with the Recycle Parameter.

```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
18 changes: 15 additions & 3 deletions src/Commands/Lists/RemoveList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class RemoveList : PnPWebCmdlet

[Parameter(Mandatory = false)]
public SwitchParameter Force;

[Parameter(Mandatory = false)]
public SwitchParameter LargeList;
protected override void ExecuteCmdlet()
{
var list = Identity.GetList(CurrentWeb);
Expand All @@ -33,9 +36,18 @@ protected override void ExecuteCmdlet()
{
if (Recycle)
{
var recycleResult = list.Recycle();
ClientContext.ExecuteQueryRetry();
WriteObject(new RecycleResult { RecycleBinItemId = recycleResult.Value });
if (LargeList)
{
var operationId = list.StartRecycle();
ClientContext.ExecuteQueryRetry();
WriteObject($"Large List Operation Job {operationId.Value} initiated. It may take a while for this job to complete.");
}
else
{
var recycleResult = list.Recycle();
ClientContext.ExecuteQueryRetry();
WriteObject(new RecycleResult { RecycleBinItemId = recycleResult.Value });
}
}
else
{
Expand Down

0 comments on commit d05347d

Please sign in to comment.