From eb53d995d00ab6fd3f8dafd5bbe30e713f1963ad Mon Sep 17 00:00:00 2001 From: lileadai Date: Tue, 18 Apr 2023 13:17:28 -0700 Subject: [PATCH 1/6] Add Get-LargeListRemovalStatus cmd --- .../Lists/GetLargeListRemovalStatus.cs | 26 +++++++++++++++++++ src/Commands/Lists/RemoveList.cs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/Commands/Lists/GetLargeListRemovalStatus.cs diff --git a/src/Commands/Lists/GetLargeListRemovalStatus.cs b/src/Commands/Lists/GetLargeListRemovalStatus.cs new file mode 100644 index 000000000..1b440eb24 --- /dev/null +++ b/src/Commands/Lists/GetLargeListRemovalStatus.cs @@ -0,0 +1,26 @@ +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, "LargeLisRemovalStatus")] + public class GetLargeLisRemovalStatus : PnPWebCmdlet + { + [Parameter(Mandatory = true)] + public Guid ListId; + + [Parameter(Mandatory = true)] + public Guid OperationId; + + protected override void ExecuteCmdlet() + { + var operation = CurrentWeb.GetListOperation(ListId, OperationId); + Console.WriteLine($"OperationType: {operation.OperationType}, ResourceLocation: {operation.ResourceLocation}, Status: {operation.Status}, ProgressPercentage: {operation.ProgressPercentage}"); + } + } +} \ No newline at end of file diff --git a/src/Commands/Lists/RemoveList.cs b/src/Commands/Lists/RemoveList.cs index 088c9e056..1b90f95ef 100644 --- a/src/Commands/Lists/RemoveList.cs +++ b/src/Commands/Lists/RemoveList.cs @@ -41,7 +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."); + WriteVerbose($"Large List Operation Job {operationId.Value} initiated for list {list.Id}. Run Get-LargeListRemovalStatus -ListId {list.Id} -OperationId {operationId.Value} to check the status of the job"); WriteObject(new RecycleResult { RecycleBinItemId = operationId.Value }); } else From b2875939f77ddf066109de2b74e749ad1d341b41 Mon Sep 17 00:00:00 2001 From: lileadai Date: Tue, 18 Apr 2023 17:31:42 -0700 Subject: [PATCH 2/6] Command working --- .../Lists/GetLargeListRemovalStatus.cs | 10 ++++++---- src/Commands/Lists/RemoveList.cs | 3 +-- src/Commands/Model/SharePoint/RecycleResult.cs | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Commands/Lists/GetLargeListRemovalStatus.cs b/src/Commands/Lists/GetLargeListRemovalStatus.cs index 1b440eb24..543ac6ccd 100644 --- a/src/Commands/Lists/GetLargeListRemovalStatus.cs +++ b/src/Commands/Lists/GetLargeListRemovalStatus.cs @@ -8,8 +8,8 @@ namespace PnP.PowerShell.Commands.Lists { - [Cmdlet(VerbsCommon.Get, "LargeLisRemovalStatus")] - public class GetLargeLisRemovalStatus : PnPWebCmdlet + [Cmdlet(VerbsCommon.Get, "LargeListRemovalStatus")] + public class GetLargeListRemovalStatus : PnPWebCmdlet { [Parameter(Mandatory = true)] public Guid ListId; @@ -19,8 +19,10 @@ public class GetLargeLisRemovalStatus : PnPWebCmdlet protected override void ExecuteCmdlet() { - var operation = CurrentWeb.GetListOperation(ListId, OperationId); - Console.WriteLine($"OperationType: {operation.OperationType}, ResourceLocation: {operation.ResourceLocation}, Status: {operation.Status}, ProgressPercentage: {operation.ProgressPercentage}"); + 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 1b90f95ef..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 for list {list.Id}. Run Get-LargeListRemovalStatus -ListId {list.Id} -OperationId {operationId.Value} to check the status of the job"); - 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..d189eec3f 100644 --- a/src/Commands/Model/SharePoint/RecycleResult.cs +++ b/src/Commands/Model/SharePoint/RecycleResult.cs @@ -5,5 +5,23 @@ namespace PnP.PowerShell.Commands.Model.SharePoint public sealed class RecycleResult { public Guid RecycleBinItemId { get; set; } + public string RecycleBinLargeOperationType { get; set; } + public string RecycleBinLargeOperationResourceLocation { get; set; } + public string RecycleBinLargeOperationStatus { get; set; } + public double RecycleBinLargeOperationProgressPercentage { 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; } } } From cf8a67f0b9cd17d23e913fff0e5120bf901a3044 Mon Sep 17 00:00:00 2001 From: lileadai Date: Tue, 18 Apr 2023 17:46:21 -0700 Subject: [PATCH 3/6] Add documentation and rename LargelistOperationStatus --- documentation/Get-LargeListRemovalStatus.md | 30 +++++++++++++++++++ documentation/Remove-PnPList.md | 2 +- ...atus.cs => GetLargeListOperationStatus.cs} | 4 +-- .../Model/SharePoint/RecycleResult.cs | 4 --- 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 documentation/Get-LargeListRemovalStatus.md rename src/Commands/Lists/{GetLargeListRemovalStatus.cs => GetLargeListOperationStatus.cs} (88%) diff --git a/documentation/Get-LargeListRemovalStatus.md b/documentation/Get-LargeListRemovalStatus.md new file mode 100644 index 000000000..c170b2d3d --- /dev/null +++ b/documentation/Get-LargeListRemovalStatus.md @@ -0,0 +1,30 @@ +--- +Module Name: PnP.PowerShell +title: Get-LargeListOperationStatus +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Get-LargeListRemovalStatus.html +--- + +# Get-LargeListOperationStatus + +## SYNOPSIS +Get the status of a large list operation. Currently supports Large List Removal Operation. + +## SYNTAX + +```powershell +Get-LargeListOperationStatus [-ListId] [-OperationId] [-Connection ] +``` + +## DESCRIPTION + +Allows to get the status of a large list operation. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-LargeListOperationStatus -ListId 9ea5d197-2227-4156-9ae1-725d74dc029d -OperationId 924e6a34-5c90-4d0d-8083-2efc6d1cf481 +``` \ No newline at end of file diff --git a/documentation/Remove-PnPList.md b/documentation/Remove-PnPList.md index e1728dd5f..ac9b7f671 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-LargeListRemovalStatus -ListId -OperationId to check the status of the operation. ## PARAMETERS diff --git a/src/Commands/Lists/GetLargeListRemovalStatus.cs b/src/Commands/Lists/GetLargeListOperationStatus.cs similarity index 88% rename from src/Commands/Lists/GetLargeListRemovalStatus.cs rename to src/Commands/Lists/GetLargeListOperationStatus.cs index 543ac6ccd..380e36d03 100644 --- a/src/Commands/Lists/GetLargeListRemovalStatus.cs +++ b/src/Commands/Lists/GetLargeListOperationStatus.cs @@ -8,8 +8,8 @@ namespace PnP.PowerShell.Commands.Lists { - [Cmdlet(VerbsCommon.Get, "LargeListRemovalStatus")] - public class GetLargeListRemovalStatus : PnPWebCmdlet + [Cmdlet(VerbsCommon.Get, "LargeListOperationStatus")] + public class GetLargeListOperationStatus : PnPWebCmdlet { [Parameter(Mandatory = true)] public Guid ListId; diff --git a/src/Commands/Model/SharePoint/RecycleResult.cs b/src/Commands/Model/SharePoint/RecycleResult.cs index d189eec3f..df5d908b1 100644 --- a/src/Commands/Model/SharePoint/RecycleResult.cs +++ b/src/Commands/Model/SharePoint/RecycleResult.cs @@ -5,10 +5,6 @@ namespace PnP.PowerShell.Commands.Model.SharePoint public sealed class RecycleResult { public Guid RecycleBinItemId { get; set; } - public string RecycleBinLargeOperationType { get; set; } - public string RecycleBinLargeOperationResourceLocation { get; set; } - public string RecycleBinLargeOperationStatus { get; set; } - public double RecycleBinLargeOperationProgressPercentage { get; set; } } public sealed class RecycleBinLargeOperation From 64a7f87140ec25d9cea7fdd81f3f15673efa35d5 Mon Sep 17 00:00:00 2001 From: lileadai Date: Tue, 18 Apr 2023 17:56:11 -0700 Subject: [PATCH 4/6] Rename LargeListRemovalStatus --- ...argeListRemovalStatus.md => Get-LargeListOperationStatus.md} | 2 +- documentation/Remove-PnPList.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename documentation/{Get-LargeListRemovalStatus.md => Get-LargeListOperationStatus.md} (96%) diff --git a/documentation/Get-LargeListRemovalStatus.md b/documentation/Get-LargeListOperationStatus.md similarity index 96% rename from documentation/Get-LargeListRemovalStatus.md rename to documentation/Get-LargeListOperationStatus.md index c170b2d3d..cf213ef5b 100644 --- a/documentation/Get-LargeListRemovalStatus.md +++ b/documentation/Get-LargeListOperationStatus.md @@ -4,7 +4,7 @@ title: Get-LargeListOperationStatus schema: 2.0.0 applicable: SharePoint Online external help file: PnP.PowerShell.dll-Help.xml -online version: https://pnp.github.io/powershell/cmdlets/Get-LargeListRemovalStatus.html +online version: https://pnp.github.io/powershell/cmdlets/Get-LargeListOperationStatus.html --- # Get-LargeListOperationStatus diff --git a/documentation/Remove-PnPList.md b/documentation/Remove-PnPList.md index ac9b7f671..8429c4764 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-LargeListRemovalStatus -ListId -OperationId to check the status of the operation. +Run Get-LargeListOperationStatus -ListId -OperationId to check the status of the operation. ## PARAMETERS From 36557004f5094ec60f05e86f1db3105f64d293e2 Mon Sep 17 00:00:00 2001 From: lileadai Date: Mon, 24 Apr 2023 11:15:14 -0700 Subject: [PATCH 5/6] Rename to Get-PnPLargeListOperationStatus --- documentation/Get-LargeListOperationStatus.md | 30 ------------------- .../Get-PnPLargeListOperationStatus.md | 30 +++++++++++++++++++ documentation/Remove-PnPList.md | 2 +- .../Lists/GetLargeListOperationStatus.cs | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 documentation/Get-LargeListOperationStatus.md create mode 100644 documentation/Get-PnPLargeListOperationStatus.md diff --git a/documentation/Get-LargeListOperationStatus.md b/documentation/Get-LargeListOperationStatus.md deleted file mode 100644 index cf213ef5b..000000000 --- a/documentation/Get-LargeListOperationStatus.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -Module Name: PnP.PowerShell -title: Get-LargeListOperationStatus -schema: 2.0.0 -applicable: SharePoint Online -external help file: PnP.PowerShell.dll-Help.xml -online version: https://pnp.github.io/powershell/cmdlets/Get-LargeListOperationStatus.html ---- - -# Get-LargeListOperationStatus - -## SYNOPSIS -Get the status of a large list operation. Currently supports Large List Removal Operation. - -## SYNTAX - -```powershell -Get-LargeListOperationStatus [-ListId] [-OperationId] [-Connection ] -``` - -## DESCRIPTION - -Allows to get the status of a large list operation. - -## EXAMPLES - -### EXAMPLE 1 -```powershell -Get-LargeListOperationStatus -ListId 9ea5d197-2227-4156-9ae1-725d74dc029d -OperationId 924e6a34-5c90-4d0d-8083-2efc6d1cf481 -``` \ No newline at end of file diff --git a/documentation/Get-PnPLargeListOperationStatus.md b/documentation/Get-PnPLargeListOperationStatus.md new file mode 100644 index 000000000..5f90b533c --- /dev/null +++ b/documentation/Get-PnPLargeListOperationStatus.md @@ -0,0 +1,30 @@ +--- +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 +``` \ No newline at end of file diff --git a/documentation/Remove-PnPList.md b/documentation/Remove-PnPList.md index 8429c4764..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-LargeListOperationStatus -ListId -OperationId to check the status of the operation. +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 index 380e36d03..8661d7c64 100644 --- a/src/Commands/Lists/GetLargeListOperationStatus.cs +++ b/src/Commands/Lists/GetLargeListOperationStatus.cs @@ -8,7 +8,7 @@ namespace PnP.PowerShell.Commands.Lists { - [Cmdlet(VerbsCommon.Get, "LargeListOperationStatus")] + [Cmdlet(VerbsCommon.Get, "PnPLargeListOperationStatus")] public class GetLargeListOperationStatus : PnPWebCmdlet { [Parameter(Mandatory = true)] From 89061bd693e73625c698e6dac9bc7f6e4ff340a2 Mon Sep 17 00:00:00 2001 From: lileadai Date: Tue, 25 Apr 2023 11:23:36 -0700 Subject: [PATCH 6/6] Update documentatuib --- .../Get-PnPLargeListOperationStatus.md | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/documentation/Get-PnPLargeListOperationStatus.md b/documentation/Get-PnPLargeListOperationStatus.md index 5f90b533c..59d874bcc 100644 --- a/documentation/Get-PnPLargeListOperationStatus.md +++ b/documentation/Get-PnPLargeListOperationStatus.md @@ -27,4 +27,52 @@ Allows to get the status of a large list operation. ### EXAMPLE 1 ```powershell Get-PnPLargeListOperationStatus -ListId 9ea5d197-2227-4156-9ae1-725d74dc029d -OperationId 924e6a34-5c90-4d0d-8083-2efc6d1cf481 -``` \ No newline at end of file +``` + +## 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