diff --git a/documentation/Get-PnPLargeListOperationStatus.md b/documentation/Get-PnPLargeListOperationStatus.md new file mode 100644 index 000000000..59d874bcc --- /dev/null +++ b/documentation/Get-PnPLargeListOperationStatus.md @@ -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] [-OperationId] [-Connection ] +``` + +## 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) \ No newline at end of file diff --git a/documentation/Remove-PnPList.md b/documentation/Remove-PnPList.md index e1728dd5f..356837fca 100644 --- a/documentation/Remove-PnPList.md +++ b/documentation/Remove-PnPList.md @@ -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 -OperationId to check the status of the operation. ## PARAMETERS diff --git a/src/Commands/Lists/GetLargeListOperationStatus.cs b/src/Commands/Lists/GetLargeListOperationStatus.cs new file mode 100644 index 000000000..8661d7c64 --- /dev/null +++ b/src/Commands/Lists/GetLargeListOperationStatus.cs @@ -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}); + } + } +} \ No newline at end of file diff --git a/src/Commands/Lists/RemoveList.cs b/src/Commands/Lists/RemoveList.cs index 088c9e056..e7e47fdd6 100644 --- a/src/Commands/Lists/RemoveList.cs +++ b/src/Commands/Lists/RemoveList.cs @@ -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 { diff --git a/src/Commands/Model/SharePoint/RecycleResult.cs b/src/Commands/Model/SharePoint/RecycleResult.cs index 23b46c73c..df5d908b1 100644 --- a/src/Commands/Model/SharePoint/RecycleResult.cs +++ b/src/Commands/Model/SharePoint/RecycleResult.cs @@ -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; } + } }