Skip to content

Commit

Permalink
Add Get-LargelistOperationStatus (#3033)
Browse files Browse the repository at this point in the history
* Add Get-LargeListRemovalStatus cmd

* Command working

* Add documentation and rename LargelistOperationStatus

* Rename LargeListRemovalStatus

* Rename to Get-PnPLargeListOperationStatus

* Update documentatuib

---------

Co-authored-by: Gautam Sheth <[email protected]>
  • Loading branch information
lilealdai and gautamdsheth authored Apr 26, 2023
1 parent 07ae699 commit 23fb088
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 3 deletions.
78 changes: 78 additions & 0 deletions documentation/Get-PnPLargeListOperationStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
Module Name: PnP.PowerShell
title: Get-PnPLargeListOperationStatus
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLargeListOperationStatus.html
---

# Get-PnPLargeListOperationStatus

## SYNOPSIS
Get the status of a large list operation. Currently supports Large List Removal Operation.

## SYNTAX

```powershell
Get-PnPLargeListOperationStatus [-ListId] <ListId> [-OperationId] <OperationId> [-Connection <PnPConnection>]
```

## DESCRIPTION

Allows to get the status of a large list operation.

## EXAMPLES

### EXAMPLE 1
```powershell
Get-PnPLargeListOperationStatus -ListId 9ea5d197-2227-4156-9ae1-725d74dc029d -OperationId 924e6a34-5c90-4d0d-8083-2efc6d1cf481
```

## PARAMETERS

### -ListId
ListId/Guid of the list. Retrieve the value for this parameter from the output of the Large List Operation Command.

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

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -OperationId
OperationId/Guid of the Large List Operation. Retrieve the value for this parameter from the output of the Large List Operation Command.
```yaml
Type: Guid
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
## RELATED LINKS
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
2 changes: 1 addition & 1 deletion documentation/Remove-PnPList.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Remove-PnPList -Identity Announcements -Recycle -LargeList
```

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

Run Get-PnPLargeListOperationStatus -ListId <ListId> -OperationId <OperationId> to check the status of the operation.

## PARAMETERS

Expand Down
28 changes: 28 additions & 0 deletions src/Commands/Lists/GetLargeListOperationStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Management.Automation;

using Microsoft.SharePoint.Client;

using PnP.PowerShell.Commands.Base.PipeBinds;
using PnP.PowerShell.Commands.Model.SharePoint;

namespace PnP.PowerShell.Commands.Lists
{
[Cmdlet(VerbsCommon.Get, "PnPLargeListOperationStatus")]
public class GetLargeListOperationStatus : PnPWebCmdlet
{
[Parameter(Mandatory = true)]
public Guid ListId;

[Parameter(Mandatory = true)]
public Guid OperationId;

protected override void ExecuteCmdlet()
{
var operation = ClientContext.Web.GetListOperation(ListId, OperationId);
ClientContext.Load(operation);
ClientContext.ExecuteQueryRetry();
WriteObject(new RecycleBinLargeOperationResult { RecycleBinLargeOperationType = operation.OperationType, RecycleBinLargeOperationResourceLocation = operation.ResourceLocation, RecycleBinLargeOperationStatus = operation.Status, RecycleBinLargeOperationProgressPercentage = operation.ProgressPercentage});
}
}
}
3 changes: 1 addition & 2 deletions src/Commands/Lists/RemoveList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ protected override void ExecuteCmdlet()
{
var operationId = list.StartRecycle();
ClientContext.ExecuteQueryRetry();
WriteVerbose($"Large List Operation Job {operationId.Value} initiated. It may take a while for this job to complete.");
WriteObject(new RecycleResult { RecycleBinItemId = operationId.Value });
WriteObject(new RecycleBinLargeOperation { RecycleBinLargeOperationId = operationId.Value, ListId = list.Id });
}
else
{
Expand Down
14 changes: 14 additions & 0 deletions src/Commands/Model/SharePoint/RecycleResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ public sealed class RecycleResult
{
public Guid RecycleBinItemId { get; set; }
}

public sealed class RecycleBinLargeOperation
{
public Guid ListId { get; set; }
public Guid RecycleBinLargeOperationId { get; set; }
}

public sealed class RecycleBinLargeOperationResult
{
public string RecycleBinLargeOperationType { get; set; }
public string RecycleBinLargeOperationResourceLocation { get; set; }
public string RecycleBinLargeOperationStatus { get; set; }
public double RecycleBinLargeOperationProgressPercentage { get; set; }
}
}

0 comments on commit 23fb088

Please sign in to comment.