From 00bb7d2b788965fd8500fc4ae0109e7fba792eaf Mon Sep 17 00:00:00 2001 From: jennywu Date: Wed, 13 Mar 2024 12:30:55 -0700 Subject: [PATCH 1/4] [FileVersion] Add and update batch delete cmdlets --- ...ibraryFileVersionBatchDeleteJobProgress.md | 65 +++++++++++ ...nPSiteFileVersionBatchDeleteJobProgress.md | 51 +++++++++ ...New-PnPLibraryFileVersionBatchDeleteJob.md | 62 ++++++++++- .../New-PnPSiteFileVersionBatchDeleteJob.md | 62 ++++++++++- ...ibraryFileVersionBatchDeleteJobProgress.cs | 58 ++++++++++ .../NewLibraryFileVersionBatchDeleteJob.cs | 50 ++++++++- .../FileVersionBatchDeleteJobProgress.cs | 104 ++++++++++++++++++ .../SharePoint/SetVersionPolicyProgress.cs | 18 ++- .../SetVersionPolicyProgressClient.cs | 75 ------------- .../Site/GetSetVersionPolicyProgress.cs | 21 +--- ...etSiteFileVersionBatchDeleteJobProgress.cs | 50 +++++++++ .../Site/NewSiteFileVersionBatchDeleteJob.cs | 49 ++++++++- 12 files changed, 558 insertions(+), 107 deletions(-) create mode 100644 documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md create mode 100644 documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md create mode 100644 src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs create mode 100644 src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs delete mode 100644 src/Commands/Model/SharePoint/SetVersionPolicyProgressClient.cs create mode 100644 src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs diff --git a/documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md b/documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md new file mode 100644 index 000000000..ba1f96252 --- /dev/null +++ b/documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md @@ -0,0 +1,65 @@ +--- +Module Name: PnP.PowerShell +schema: 2.0.0 +applicable: SharePoint Online +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionBatchDeleteJobProgress.html +external help file: PnP.PowerShell.dll-Help.xml +title: Get-PnPLibraryFileVersionBatchDeleteJobProgress +--- + +# Get-PnPLibraryFileVersionBatchDeleteJobProgress + +## SYNOPSIS +Get the progress of deleting existing file versions on the document library. + +## SYNTAX + +```powershell +Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity [-Connection ] +``` + +## DESCRIPTION +This cmdlet allows retrieval of the progress of deleting existing file versions on the document library. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity "Documents" +``` + +Returns the progress of deleting existing file versions on the document library. + +## PARAMETERS + +### -Identity +The ID, name or Url (Lists/MyList) of the document library to perform the trimming on. + +```yaml +Type: ListPipeBind +Parameter Sets: (All) + +Required: True +Position: 0 +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) diff --git a/documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md b/documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md new file mode 100644 index 000000000..b15393b11 --- /dev/null +++ b/documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md @@ -0,0 +1,51 @@ +--- +Module Name: PnP.PowerShell +schema: 2.0.0 +applicable: SharePoint Online +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionBatchDeleteJobProgress.html +external help file: PnP.PowerShell.dll-Help.xml +title: Get-PnPSiteFileVersionBatchDeleteJobProgress +--- + +# Get-PnPSiteFileVersionBatchDeleteJobProgress + +## SYNOPSIS +Get the progress of deleting existing file versions on the site. + +## SYNTAX + +```powershell +Get-PnPSiteFileVersionBatchDeleteJobProgress [-Connection ] +``` + +## DESCRIPTION +This cmdlet allows retrieval of the progress of deleting existing file versions on the site. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-PnPSiteFileVersionBatchDeleteJobProgress +``` + +Returns the progress of deleting existing file versions on the site. + +## PARAMETERS + +### -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) diff --git a/documentation/New-PnPLibraryFileVersionBatchDeleteJob.md b/documentation/New-PnPLibraryFileVersionBatchDeleteJob.md index 71bf27f0a..d9ca6b4a9 100644 --- a/documentation/New-PnPLibraryFileVersionBatchDeleteJob.md +++ b/documentation/New-PnPLibraryFileVersionBatchDeleteJob.md @@ -30,14 +30,28 @@ Starts a file version batch trim job for a document library. New-PnPLibraryFileVersionBatchDeleteJob -Identity "Documents" -DeleteBeforeDays 360 ``` -Starts a file version batch trim job that will delete all file verions that are over 360 days old in the document library. +Starts a file version batch trim job that will delete all file versions that are over 360 days old in the document library. ### EXAMPLE 2 ```powershell New-PnPLibraryFileVersionBatchDeleteJob -Identity "Documents" -DeleteBeforeDays 360 -Force ``` -Starts a file version batch trim job that will delete all file verions that are over 360 days old in the document library, without prompting the user for confirmation. +Starts a file version batch trim job that will delete all file versions that are over 360 days old in the document library, without prompting the user for confirmation. + +### EXAMPLE 3 +```powershell +New-PnPLibraryFileVersionBatchDeleteJob -Automatic +``` + +Starts a file version batch trim job that will delete file versions that expiread and set version expiration time for the ones not expired in the document library based on the backend algorithm. + +### EXAMPLE 4 +```powershell +New-PnPLibraryFileVersionBatchDeleteJob -MajorVersionLimit 30 -MajorWithMinorVersionsLimit 10 +``` + +Starts a file version batch trim job that will delete file versions in the document library based on the version count limits. ## PARAMETERS @@ -60,7 +74,7 @@ The minimum age of file versions to trim. In other words, all file versions that ```yaml Type: int -Parameter Sets: (All) +Parameter Sets: DeleteOlderThanDays Required: True Position: Named @@ -69,6 +83,48 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Automatic +Trim file version using automatic trim. + +```yaml +Type: SwitchParameter +Parameter Sets: AutomaticTrim + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MajorVersionLimit +Trim file version using version count limits. Need to specify MajorWithMinorVersionsLimit as well. + +```yaml +Type: int +Parameter Sets: CountLimits + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MajorWithMinorVersionsLimit +Trim file version using version count limits. Need to specify MajorVersionLimit as well. + +```yaml +Type: int +Parameter Sets: CountLimits + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Force When provided, no confirmation prompts will be shown to the user. diff --git a/documentation/New-PnPSiteFileVersionBatchDeleteJob.md b/documentation/New-PnPSiteFileVersionBatchDeleteJob.md index 826d1c606..83d360265 100644 --- a/documentation/New-PnPSiteFileVersionBatchDeleteJob.md +++ b/documentation/New-PnPSiteFileVersionBatchDeleteJob.md @@ -30,14 +30,28 @@ Starts a file version batch trim job targeting all document libraries in a site New-PnPSiteFileVersionBatchDeleteJob -DeleteBeforeDays 360 ``` -Starts a file version batch trim job that will delete all file verions that are over 360 days old in all document libraries in the site collection. +Starts a file version batch trim job that will delete all file versions that are over 360 days old in all document libraries in the site collection. ### EXAMPLE 2 ```powershell New-PnPSiteFileVersionBatchDeleteJob -DeleteBeforeDays 360 -Force ``` -Starts a file version batch trim job that will delete all file verions that are over 360 days old in all document libraries in the site collection, without prompting the user for confirmation. +Starts a file version batch trim job that will delete all file versions that are over 360 days old in all document libraries in the site collection, without prompting the user for confirmation. + +### EXAMPLE 3 +```powershell +New-PnPSiteFileVersionBatchDeleteJob -Automatic +``` + +Starts a file version batch trim job that will delete file versions that expiread and set version expiration time for the ones not expired in the site collection based on the backend algorithm. + +### EXAMPLE 4 +```powershell +New-PnPSiteFileVersionBatchDeleteJob -MajorVersionLimit 30 -MajorWithMinorVersionsLimit 10 +``` + +Starts a file version batch trim job that will delete file versions in the site collection based on the version count limits. ## PARAMETERS @@ -46,7 +60,7 @@ The minimum age of file versions to trim. In other words, all file versions that ```yaml Type: int -Parameter Sets: (All) +Parameter Sets: DeleteOlderThanDays Required: True Position: Named @@ -55,6 +69,48 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Automatic +Trim file version using automatic trim. + +```yaml +Type: SwitchParameter +Parameter Sets: AutomaticTrim + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MajorVersionLimit +Trim file version using version count limits. Need to specify MajorWithMinorVersionsLimit as well. + +```yaml +Type: int +Parameter Sets: CountLimits + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MajorWithMinorVersionsLimit +Trim file version using version count limits. Need to specify MajorVersionLimit as well. + +```yaml +Type: int +Parameter Sets: CountLimits + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Force When provided, no confirmation prompts will be shown to the user. diff --git a/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs b/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs new file mode 100644 index 000000000..2769c3dd6 --- /dev/null +++ b/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs @@ -0,0 +1,58 @@ +using Microsoft.SharePoint.Client; + +using PnP.Framework.Utilities; +using PnP.PowerShell.Commands.Base.PipeBinds; +using PnP.PowerShell.Commands.Model.SharePoint; +using System; +using System.Management.Automation; +using System.Text.Json; + +namespace PnP.PowerShell.Commands.Lists +{ + [Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionBatchDeleteJobProgress")] + [OutputType(typeof(FileVersionBatchDeleteJobProgress))] + public class GetLibraryFileVersionBatchDeleteJobProgress : PnPWebCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] + [ValidateNotNull] + public ListPipeBind Identity; + + protected override void ExecuteCmdlet() + { + var list = Identity.GetList(CurrentWeb); + if (list != null) + { + var ret = list.GetProgressForDeleteFileVersions(); + ClientContext.ExecuteQueryRetry(); + + var progress = JsonSerializer.Deserialize(ret.Value); + var connectionUrl = new Uri(Connection.Url); + var serverUrl = string.Concat("https://", connectionUrl.Host); + progress.Url = string.Concat(serverUrl, list.RootFolder.ServerRelativeUrl); + + if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.DeleteOlderThanDays.ToString(), StringComparison.OrdinalIgnoreCase)) + { + progress.DeleteOlderThan = string.Empty; + } + + if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.CountLimits.ToString(), StringComparison.OrdinalIgnoreCase)) + { + progress.MajorVersionLimit = string.Empty; + progress.MajorWithMinorVersionsLimit = string.Empty; + } + + if (string.Equals(progress.LastProcessTimeInUTC, DateTime.MinValue.ToString())) + { + progress.LastProcessTimeInUTC = string.Empty; + } + + if (string.Equals(progress.CompleteTimeInUTC, DateTime.MinValue.ToString())) + { + progress.CompleteTimeInUTC = string.Empty; + } + + WriteObject(progress); + } + } + } +} diff --git a/src/Commands/Lists/NewLibraryFileVersionBatchDeleteJob.cs b/src/Commands/Lists/NewLibraryFileVersionBatchDeleteJob.cs index 98ffeb941..0109a3dc5 100644 --- a/src/Commands/Lists/NewLibraryFileVersionBatchDeleteJob.cs +++ b/src/Commands/Lists/NewLibraryFileVersionBatchDeleteJob.cs @@ -12,24 +12,70 @@ namespace PnP.PowerShell.Commands.Lists [Cmdlet(VerbsCommon.New, "PnPLibraryFileVersionBatchDeleteJob")] public class NewLibraryFileVersionBatchDeleteJob : PnPWebCmdlet { + private const string ParameterSet_AUTOMATICTRIM = "AutomaticTrim"; + private const string ParameterSet_DELETEOLDERTHANDAYS = "DeleteOlderThanDays"; + private const string ParameterSet_COUNTLIMITS = "CountLimits"; + [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] [ValidateNotNull] public ListPipeBind Identity; - [Parameter(Mandatory = true)] + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_AUTOMATICTRIM)] + public SwitchParameter Automatic; + + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_DELETEOLDERTHANDAYS)] public int DeleteBeforeDays; + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_COUNTLIMITS)] + public int MajorVersionLimit; + + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_COUNTLIMITS)] + public int MajorWithMinorVersionsLimit; + [Parameter(Mandatory = false)] public SwitchParameter Force; protected override void ExecuteCmdlet() { + FileVersionBatchDeleteMode batchDeleteMode; + if (Automatic) + { + batchDeleteMode = FileVersionBatchDeleteMode.AutomaticTrim; + DeleteBeforeDays = -1; + MajorVersionLimit = -1; + MajorWithMinorVersionsLimit = -1; + } + else if (ParameterSpecified(nameof(DeleteBeforeDays))) + { + batchDeleteMode = FileVersionBatchDeleteMode.DeleteOlderThanDays; + MajorVersionLimit = -1; + MajorWithMinorVersionsLimit = -1; + } + else if (ParameterSpecified(nameof(MajorVersionLimit)) || + ParameterSpecified(nameof(MajorWithMinorVersionsLimit))) + { + batchDeleteMode = FileVersionBatchDeleteMode.CountLimits; + DeleteBeforeDays = -1; + } + else + { + throw new PSArgumentException($"One or more parameters issued cannot be used together or an insufficient number of parameters were provided. Specify Automatic for automatic trim. Specify DeleteBeforeDays for delete older than days. Specify MajorVersionLimit and MajorWithMinorVersionsLimit for version count limits."); + } + if (Force || ShouldContinue("By executing this command, versions specified will be permanently deleted. These versions cannot be restored from the recycle bin. Are you sure you want to continue?", Resources.Confirm)) { var list = Identity.GetList(CurrentWeb); if (list != null) { - list.StartDeleteFileVersions(DeleteBeforeDays); + var ps = new FileVersionBatchDeleteParameters(); + + ps.BatchDeleteMode = batchDeleteMode; + ps.DeleteOlderThanDays = DeleteBeforeDays; + ps.MajorVersionLimit = MajorVersionLimit; + ps.MajorWithMinorVersionsLimit = MajorWithMinorVersionsLimit; + + list.StartDeleteFileVersionsByMode(ps); + ClientContext.ExecuteQueryRetry(); WriteObject("Success. Versions specified will be permanently deleted in the upcoming days."); diff --git a/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs new file mode 100644 index 000000000..49a29853a --- /dev/null +++ b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace PnP.PowerShell.Commands.Model.SharePoint +{ + /// + /// The progress for the request that batch delete file versions + /// + public class FileVersionBatchDeleteJobProgress + { + /// + /// Site/Library Url + /// + public string Url { get; set; } + + /// + /// The workitem Id related to the request + /// + [JsonPropertyName("WorkItemId")] + public string WorkItemId { get; set; } + + /// + /// The request status + /// + [JsonPropertyName("Status")] + public string Status { get; set; } + + /// + /// The UTC time user sent the request + /// + [JsonPropertyName("RequestTimeInUTC")] + public string RequestTimeInUTC { get; set; } + + /// + /// The UTC time the server last processed the request + /// + [JsonPropertyName("LastProcessTimeInUTC")] + public string LastProcessTimeInUTC { get; set; } + + /// + /// The UTC time the request completes + /// + [JsonPropertyName("CompleteTimeInUTC")] + public string CompleteTimeInUTC { get; set; } + + /// + /// The batch delete mode + /// + [JsonPropertyName("BatchDeleteMode")] + public string BatchDeleteMode { get; set; } + + /// + /// Delete older than when BatchDeleteMode is DeleteOlderThanDays + /// + [JsonPropertyName("DeleteOlderThan")] + public string DeleteOlderThan { get; set; } + + /// + /// MajorVersionLimit when BatchDeleteMode is CountLimits + /// + [JsonPropertyName("MajorVersionLimit")] + public string MajorVersionLimit { get; set; } + + /// + /// MajorWithMinorVersionsLimit when BatchDeleteMode is CountLimits + /// + [JsonPropertyName("MajorWithMinorVersionsLimit")] + public string MajorWithMinorVersionsLimit { get; set; } + + /// + /// The files processed count + /// + [JsonPropertyName("FilesProcessed")] + public string FilesProcessed { get; set; } + + /// + /// The versions failed to process count + /// + [JsonPropertyName("VersionsProcessed")] + public string VersionsProcessed { get; set; } + + /// + /// Set versions deleted count + /// + [JsonPropertyName("VersionsDeleted")] + public string VersionsDeleted { get; set; } + + /// + /// The versions failed to delete count + /// + [JsonPropertyName("VersionsFailed")] + public string VersionsFailed { get; set; } + + /// + /// The storage released + /// + [JsonPropertyName("StorageReleased")] + public string StorageReleasedInBytes { get; set; } + } +} diff --git a/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs b/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs index 0bb6d3f01..f587ca6c3 100644 --- a/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs +++ b/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace PnP.PowerShell.Commands.Model.SharePoint @@ -19,57 +20,68 @@ public class SetVersionPolicyProgress /// /// The workitem Id related to the request /// + [JsonPropertyName("WorkItemId")] public string WorkItemId { get; set; } /// /// The request status /// + [JsonPropertyName("Status")] public string Status { get; set; } /// /// The UTC time user sent the request /// + [JsonPropertyName("RequestTimeInUTC")] public string RequestTimeInUTC { get; set; } /// /// The UTC time the server last processed the request /// + [JsonPropertyName("LastProcessTimeInUTC")] public string LastProcessTimeInUTC { get; set; } /// /// The UTC time the request completes /// + [JsonPropertyName("CompleteTimeInUTC")] public string CompleteTimeInUTC { get; set; } /// /// The lists processed count /// - public string ListsProcessedInTotal { get; set; } + [JsonPropertyName("ListsProcessedInTotal")] + public string LibrariesProcessedInTotal { get; set; } /// /// The lists failed to process count /// - public string ListsFailedInTotal { get; set; } + [JsonPropertyName("ListsFailedInTotal")] + public string LibrariesFailedInTotal { get; set; } /// /// Set version policy as AutoExpiration or not /// - public string EnableAutoTrim { get; set; } + [JsonPropertyName("EnableAutoTrim")] + public string EnableAutomaticMode{ get; set; } /// /// The time limit if the version policy is ExpireAfter /// + [JsonPropertyName("ExpireAfterDays")] public string ExpireAfterDays { get; set; } /// /// MajorVersionLimit for the versions /// + [JsonPropertyName("MajorVersionLimit")] public string MajorVersionLimit { get; set; } /// /// MajorWithMinorVersionsLimit for the versions /// if minor version is enabled /// + [JsonPropertyName("MajorWithMinorVersionsLimit")] public string MajorWithMinorVersionsLimit { get; set; } } } diff --git a/src/Commands/Model/SharePoint/SetVersionPolicyProgressClient.cs b/src/Commands/Model/SharePoint/SetVersionPolicyProgressClient.cs deleted file mode 100644 index d5108b016..000000000 --- a/src/Commands/Model/SharePoint/SetVersionPolicyProgressClient.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PnP.PowerShell.Commands.Model.SharePoint -{ - /// - /// The progress for the request that settting version policy for existing document libraries of the site - /// - public class SetVersionPolicyProgressClient - { - /// - /// Site Url - /// - public string Url { get; set; } - - /// - /// The workitem Id related to the request - /// - public string WorkItemId { get; set; } - - /// - /// The request status - /// - public string Status { get; set; } - - /// - /// The UTC time user sent the request - /// - public string RequestTimeInUTC { get; set; } - - /// - /// The UTC time the server last processed the request - /// - public string LastProcessTimeInUTC { get; set; } - - /// - /// The UTC time the request completes - /// - public string CompleteTimeInUTC { get; set; } - - /// - /// The Libraries processed count - /// - public string LibrariesProcessedInTotal { get; set; } - - /// - /// The Libraries failed to process count - /// - public string LibrariesFailedInTotal { get; set; } - - /// - /// Set version policy as AutoExpiration or not - /// - public string EnableAutomaticMode { get; set; } - - /// - /// The time limit if the version policy is ExpireAfter - /// - public string ExpireAfterDays { get; set; } - - /// - /// MajorVersionLimit for the versions - /// - public string MajorVersionLimit { get; set; } - - /// - /// MajorWithMinorVersionsLimit for the versions - /// if minor version is enabled - /// - public string MajorWithMinorVersionsLimit { get; set; } - } -} diff --git a/src/Commands/Site/GetSetVersionPolicyProgress.cs b/src/Commands/Site/GetSetVersionPolicyProgress.cs index c8eb1477c..56987b645 100644 --- a/src/Commands/Site/GetSetVersionPolicyProgress.cs +++ b/src/Commands/Site/GetSetVersionPolicyProgress.cs @@ -9,7 +9,7 @@ namespace PnP.PowerShell.Commands.Site { [Cmdlet(VerbsCommon.Get, "PnPSiteVersionPolicyProgress")] - [OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyProgressClient))] + [OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyProgress))] public class GetSetVersionPolicyProgress : PnPSharePointCmdlet { protected override void ExecuteCmdlet() @@ -32,24 +32,7 @@ protected override void ExecuteCmdlet() progress.CompleteTimeInUTC = string.Empty; } - // Display different property names in the results using Client object - var progressClient = new SetVersionPolicyProgressClient() - { - Url = progress.Url, - WorkItemId = progress.WorkItemId, - Status = progress.Status, - RequestTimeInUTC = progress.RequestTimeInUTC, - LastProcessTimeInUTC = progress.LastProcessTimeInUTC, - CompleteTimeInUTC = progress.CompleteTimeInUTC, - LibrariesProcessedInTotal = progress.ListsProcessedInTotal, - LibrariesFailedInTotal = progress.ListsFailedInTotal, - EnableAutomaticMode = progress.EnableAutoTrim, - ExpireAfterDays = progress.ExpireAfterDays, - MajorVersionLimit = progress.MajorVersionLimit, - MajorWithMinorVersionsLimit = progress.MajorWithMinorVersionsLimit - }; - - WriteObject(progressClient); + WriteObject(progress); } } } diff --git a/src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs b/src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs new file mode 100644 index 000000000..95472a6bd --- /dev/null +++ b/src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs @@ -0,0 +1,50 @@ +using Microsoft.SharePoint.Client; + +using PnP.Framework.Utilities; +using PnP.PowerShell.Commands.Base.PipeBinds; +using PnP.PowerShell.Commands.Model.SharePoint; +using System; +using System.Management.Automation; +using System.Text.Json; + +namespace PnP.PowerShell.Commands.Sites +{ + [Cmdlet(VerbsCommon.Get, "PnPSiteFileVersionBatchDeleteJobProgress")] + [OutputType(typeof(FileVersionBatchDeleteJobProgress))] + public class GetSiteFileVersionBatchDeleteJobProgress : PnPSharePointCmdlet + { + protected override void ExecuteCmdlet() + { + var site = ClientContext.Site; + ClientContext.Load(site, s => s.Url); + var ret = site.GetProgressForDeleteFileVersions(); + ClientContext.ExecuteQueryRetry(); + + var progress = JsonSerializer.Deserialize(ret.Value); + progress.Url = site.Url; + + if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.DeleteOlderThanDays.ToString(), StringComparison.OrdinalIgnoreCase)) + { + progress.DeleteOlderThan = string.Empty; + } + + if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.CountLimits.ToString(), StringComparison.OrdinalIgnoreCase)) + { + progress.MajorVersionLimit = string.Empty; + progress.MajorWithMinorVersionsLimit = string.Empty; + } + + if (string.Equals(progress.LastProcessTimeInUTC, DateTime.MinValue.ToString())) + { + progress.LastProcessTimeInUTC = string.Empty; + } + + if (string.Equals(progress.CompleteTimeInUTC, DateTime.MinValue.ToString())) + { + progress.CompleteTimeInUTC = string.Empty; + } + + WriteObject(progress); + } + } +} diff --git a/src/Commands/Site/NewSiteFileVersionBatchDeleteJob.cs b/src/Commands/Site/NewSiteFileVersionBatchDeleteJob.cs index 6da8d9c06..06ee8b940 100644 --- a/src/Commands/Site/NewSiteFileVersionBatchDeleteJob.cs +++ b/src/Commands/Site/NewSiteFileVersionBatchDeleteJob.cs @@ -12,18 +12,63 @@ namespace PnP.PowerShell.Commands.Sites [Cmdlet(VerbsCommon.New, "PnPSiteFileVersionBatchDeleteJob")] public class NewSiteFileVersionBatchDeleteJob : PnPSharePointCmdlet { - [Parameter(Mandatory = true)] + private const string ParameterSet_AUTOMATICTRIM = "AutomaticTrim"; + private const string ParameterSet_DELETEOLDERTHANDAYS = "DeleteOlderThanDays"; + private const string ParameterSet_COUNTLIMITS = "CountLimits"; + + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_AUTOMATICTRIM)] + public SwitchParameter Automatic; + + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_DELETEOLDERTHANDAYS)] public int DeleteBeforeDays; + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_COUNTLIMITS)] + public int MajorVersionLimit; + + [Parameter(Mandatory = true, ParameterSetName = ParameterSet_COUNTLIMITS)] + public int MajorWithMinorVersionsLimit; + [Parameter(Mandatory = false)] public SwitchParameter Force; protected override void ExecuteCmdlet() { + FileVersionBatchDeleteMode batchDeleteMode; + if (Automatic) + { + batchDeleteMode = FileVersionBatchDeleteMode.AutomaticTrim; + DeleteBeforeDays = -1; + MajorVersionLimit = -1; + MajorWithMinorVersionsLimit = -1; + } + else if (ParameterSpecified(nameof(DeleteBeforeDays))) + { + batchDeleteMode = FileVersionBatchDeleteMode.DeleteOlderThanDays; + MajorVersionLimit = -1; + MajorWithMinorVersionsLimit = -1; + } + else if (ParameterSpecified(nameof(MajorVersionLimit)) || + ParameterSpecified(nameof(MajorWithMinorVersionsLimit))) + { + batchDeleteMode = FileVersionBatchDeleteMode.CountLimits; + DeleteBeforeDays = -1; + } + else + { + throw new PSArgumentException($"One or more parameters issued cannot be used together or an insufficient number of parameters were provided. Specify Automatic for automatic trim. Specify DeleteBeforeDays for delete older than days. Specify MajorVersionLimit and MajorWithMinorVersionsLimit for version count limits."); + } + if (Force || ShouldContinue("By executing this command, versions specified will be permanently deleted. These versions cannot be restored from the recycle bin. Are you sure you want to continue?", Resources.Confirm)) { var site = ClientContext.Site; - site.StartDeleteFileVersions(DeleteBeforeDays); + var ps = new FileVersionBatchDeleteParameters(); + + ps.BatchDeleteMode = batchDeleteMode; + ps.DeleteOlderThanDays = DeleteBeforeDays; + ps.MajorVersionLimit = MajorVersionLimit; + ps.MajorWithMinorVersionsLimit = MajorWithMinorVersionsLimit; + + site.StartDeleteFileVersionsByMode(ps); ClientContext.ExecuteQueryRetry(); WriteObject("Success. Versions specified will be permanently deleted in the upcoming days."); From 72ee76bfcfdaab1668f392ab86476723ac0b0a3c Mon Sep 17 00:00:00 2001 From: jennywu Date: Thu, 4 Apr 2024 00:39:24 -0700 Subject: [PATCH 2/4] Add ErrorMessage in batch delete progress --- .../Model/SharePoint/FileVersionBatchDeleteJobProgress.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs index 49a29853a..ed00b0786 100644 --- a/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs +++ b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs @@ -29,6 +29,12 @@ public class FileVersionBatchDeleteJobProgress [JsonPropertyName("Status")] public string Status { get; set; } + /// + /// The error meassage if there is any + /// + [JsonPropertyName("ErrorMessage")] + public string ErrorMessage { get; set; } + /// /// The UTC time user sent the request /// From a338286e080286a2895b62aa20cb9cfe7b4f4ed5 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Mon, 8 Apr 2024 16:14:13 +0200 Subject: [PATCH 3/4] Renaming Progress to Status as discussed --- ...> Get-PnPLibraryFileVersionBatchDeleteJobStatus.md} | 10 +++++----- ...-PnPLibraryFileVersionExpirationReportJobStatus.md} | 10 +++++----- ...d => Get-PnPSiteFileVersionBatchDeleteJobStatus.md} | 10 +++++----- ...Get-PnPSiteFileVersionExpirationReportJobStatus.md} | 10 +++++----- ...cyProgress.md => Get-PnPSiteVersionPolicyStatus.md} | 10 +++++----- ...cs => GetLibraryFileVersionBatchDeleteJobStatus.cs} | 8 ++++---- ... GetLibraryFileVersionExpirationReportJobStatus.cs} | 8 ++++---- ...bProgress.cs => FileVersionBatchDeleteJobStatus.cs} | 2 +- ...ress.cs => FileVersionExpirationReportJobStatus.cs} | 2 +- ...sionPolicyProgress.cs => SetVersionPolicyStatus.cs} | 2 +- ...nPolicyProgress.cs => GetSetVersionPolicyStatus.cs} | 8 ++++---- ...ss.cs => GetSiteFileVersionBatchDeleteJobStatus.cs} | 8 ++++---- ... => GetSiteFileVersionExpirationReportJobStatus.cs} | 8 ++++---- 13 files changed, 48 insertions(+), 48 deletions(-) rename documentation/{Get-PnPLibraryFileVersionBatchDeleteJobProgress.md => Get-PnPLibraryFileVersionBatchDeleteJobStatus.md} (80%) rename documentation/{Get-PnPLibraryFileVersionExpirationReportJobProgress.md => Get-PnPLibraryFileVersionExpirationReportJobStatus.md} (73%) rename documentation/{Get-PnPSiteFileVersionBatchDeleteJobProgress.md => Get-PnPSiteFileVersionBatchDeleteJobStatus.md} (79%) rename documentation/{Get-PnPSiteFileVersionExpirationReportJobProgress.md => Get-PnPSiteFileVersionExpirationReportJobStatus.md} (70%) rename documentation/{Get-PnPSiteVersionPolicyProgress.md => Get-PnPSiteVersionPolicyStatus.md} (85%) rename src/Commands/Lists/{GetLibraryFileVersionBatchDeleteJobProgress.cs => GetLibraryFileVersionBatchDeleteJobStatus.cs} (91%) rename src/Commands/Lists/{GetLibraryFileVersionExpirationReportJobProgress.cs => GetLibraryFileVersionExpirationReportJobStatus.cs} (84%) rename src/Commands/Model/SharePoint/{FileVersionBatchDeleteJobProgress.cs => FileVersionBatchDeleteJobStatus.cs} (98%) rename src/Commands/Model/SharePoint/{FileVersionExpirationReportJobProgress.cs => FileVersionExpirationReportJobStatus.cs} (94%) rename src/Commands/Model/SharePoint/{SetVersionPolicyProgress.cs => SetVersionPolicyStatus.cs} (98%) rename src/Commands/Site/{GetSetVersionPolicyProgress.cs => GetSetVersionPolicyStatus.cs} (85%) rename src/Commands/Site/{GetSiteFileVersionBatchDeleteJobProgress.cs => GetSiteFileVersionBatchDeleteJobStatus.cs} (86%) rename src/Commands/Site/{GetSiteFileVersionExpirationReportJobProgress.cs => GetSiteFileVersionExpirationReportJobStatus.cs} (81%) diff --git a/documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md b/documentation/Get-PnPLibraryFileVersionBatchDeleteJobStatus.md similarity index 80% rename from documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md rename to documentation/Get-PnPLibraryFileVersionBatchDeleteJobStatus.md index ba1f96252..2dd1bf2c2 100644 --- a/documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md +++ b/documentation/Get-PnPLibraryFileVersionBatchDeleteJobStatus.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionBatchDeleteJobProgress.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionBatchDeleteJobStatus.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPLibraryFileVersionBatchDeleteJobProgress +title: Get-PnPLibraryFileVersionBatchDeleteJobStatus --- -# Get-PnPLibraryFileVersionBatchDeleteJobProgress +# Get-PnPLibraryFileVersionBatchDeleteJobStatus ## SYNOPSIS Get the progress of deleting existing file versions on the document library. @@ -15,7 +15,7 @@ Get the progress of deleting existing file versions on the document library. ## SYNTAX ```powershell -Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity [-Connection ] +Get-PnPLibraryFileVersionBatchDeleteJobStatus -Identity [-Connection ] ``` ## DESCRIPTION @@ -25,7 +25,7 @@ This cmdlet allows retrieval of the progress of deleting existing file versions ### EXAMPLE 1 ```powershell -Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity "Documents" +Get-PnPLibraryFileVersionBatchDeleteJobStatus -Identity "Documents" ``` Returns the progress of deleting existing file versions on the document library. diff --git a/documentation/Get-PnPLibraryFileVersionExpirationReportJobProgress.md b/documentation/Get-PnPLibraryFileVersionExpirationReportJobStatus.md similarity index 73% rename from documentation/Get-PnPLibraryFileVersionExpirationReportJobProgress.md rename to documentation/Get-PnPLibraryFileVersionExpirationReportJobStatus.md index 5889d312c..5f26a30c3 100644 --- a/documentation/Get-PnPLibraryFileVersionExpirationReportJobProgress.md +++ b/documentation/Get-PnPLibraryFileVersionExpirationReportJobStatus.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionExpirationReportJobProgress.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionExpirationReportJobStatus.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPLibraryFileVersionExpirationReportJobProgress +title: Get-PnPLibraryFileVersionExpirationReportJobStatus --- -# Get-PnPLibraryFileVersionExpirationReportJobProgress +# Get-PnPLibraryFileVersionExpirationReportJobStatus ## SYNOPSIS @@ -16,7 +16,7 @@ Gets the status for a file version usage report generation job for a document li ## SYNTAX ```powershell -Get-PnPLibraryFileVersionExpirationReportJobProgress -Identity -ReportUrl +Get-PnPLibraryFileVersionExpirationReportJobStatus -Identity -ReportUrl ``` ## DESCRIPTION @@ -27,7 +27,7 @@ Gets the status for a file version usage report generation job for a document li ### EXAMPLE 1 ```powershell -Get-PnPLibraryFileVersionExpirationReportJobProgress -Identity "Documents" -ReportUrl "https://contoso.sharepoint.com/sites/reports/MyReports/VersionReport.csv" +Get-PnPLibraryFileVersionExpirationReportJobStatus -Identity "Documents" -ReportUrl "https://contoso.sharepoint.com/sites/reports/MyReports/VersionReport.csv" ``` Gets the status for a file version usage report generation job for a document library. diff --git a/documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md b/documentation/Get-PnPSiteFileVersionBatchDeleteJobStatus.md similarity index 79% rename from documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md rename to documentation/Get-PnPSiteFileVersionBatchDeleteJobStatus.md index b15393b11..53a46e870 100644 --- a/documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md +++ b/documentation/Get-PnPSiteFileVersionBatchDeleteJobStatus.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionBatchDeleteJobProgress.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionBatchDeleteJobStatus.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPSiteFileVersionBatchDeleteJobProgress +title: Get-PnPSiteFileVersionBatchDeleteJobStatus --- -# Get-PnPSiteFileVersionBatchDeleteJobProgress +# Get-PnPSiteFileVersionBatchDeleteJobStatus ## SYNOPSIS Get the progress of deleting existing file versions on the site. @@ -15,7 +15,7 @@ Get the progress of deleting existing file versions on the site. ## SYNTAX ```powershell -Get-PnPSiteFileVersionBatchDeleteJobProgress [-Connection ] +Get-PnPSiteFileVersionBatchDeleteJobStatus [-Connection ] ``` ## DESCRIPTION @@ -25,7 +25,7 @@ This cmdlet allows retrieval of the progress of deleting existing file versions ### EXAMPLE 1 ```powershell -Get-PnPSiteFileVersionBatchDeleteJobProgress +Get-PnPSiteFileVersionBatchDeleteJobStatus ``` Returns the progress of deleting existing file versions on the site. diff --git a/documentation/Get-PnPSiteFileVersionExpirationReportJobProgress.md b/documentation/Get-PnPSiteFileVersionExpirationReportJobStatus.md similarity index 70% rename from documentation/Get-PnPSiteFileVersionExpirationReportJobProgress.md rename to documentation/Get-PnPSiteFileVersionExpirationReportJobStatus.md index fd7f78030..cb124afa2 100644 --- a/documentation/Get-PnPSiteFileVersionExpirationReportJobProgress.md +++ b/documentation/Get-PnPSiteFileVersionExpirationReportJobStatus.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionExpirationReportJobProgress.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionExpirationReportJobStatus.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPSiteFileVersionExpirationReportJobProgress +title: Get-PnPSiteFileVersionExpirationReportJobStatus --- -# Get-PnPSiteFileVersionExpirationReportJobProgress +# Get-PnPSiteFileVersionExpirationReportJobStatus ## SYNOPSIS @@ -16,7 +16,7 @@ Gets the status for a file version usage report generation job for a site collec ## SYNTAX ```powershell -Get-PnPSiteFileVersionExpirationReportJobProgress -ReportUrl +Get-PnPSiteFileVersionExpirationReportJobStatus -ReportUrl ``` ## DESCRIPTION @@ -27,7 +27,7 @@ Gets the status for a file version usage report generation job for a site collec ### EXAMPLE 1 ```powershell -Get-PnPSiteFileVersionExpirationReportJobProgress -ReportUrl "https://contoso.sharepoint.com/sites/reports/MyReports/VersionReport.csv" +Get-PnPSiteFileVersionExpirationReportJobStatus -ReportUrl "https://contoso.sharepoint.com/sites/reports/MyReports/VersionReport.csv" ``` Gets the status for a file version usage report generation job for a site collection. diff --git a/documentation/Get-PnPSiteVersionPolicyProgress.md b/documentation/Get-PnPSiteVersionPolicyStatus.md similarity index 85% rename from documentation/Get-PnPSiteVersionPolicyProgress.md rename to documentation/Get-PnPSiteVersionPolicyStatus.md index 2fc54d287..0608378f9 100644 --- a/documentation/Get-PnPSiteVersionPolicyProgress.md +++ b/documentation/Get-PnPSiteVersionPolicyStatus.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteVersionPolicyProgress.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteVersionPolicyStatus.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPSiteVersionPolicyProgress +title: Get-PnPSiteVersionPolicyStatus --- -# Get-PnPSiteVersionPolicyProgress +# Get-PnPSiteVersionPolicyStatus ## SYNOPSIS Get the progress of setting version policy for existing document libraries on the site. @@ -15,7 +15,7 @@ Get the progress of setting version policy for existing document libraries on th ## SYNTAX ```powershell -Get-PnPSiteVersionPolicyProgress [-Connection ] +Get-PnPSiteVersionPolicyStatus [-Connection ] ``` ## DESCRIPTION @@ -25,7 +25,7 @@ This cmdlet allows retrieval of the progress of setting version policy for exist ### EXAMPLE 1 ```powershell -Get-PnPSiteVersionPolicyProgress +Get-PnPSiteVersionPolicyStatus ``` Returns the progress of setting version policy for existing document libraries on the site. diff --git a/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs b/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobStatus.cs similarity index 91% rename from src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs rename to src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobStatus.cs index 2769c3dd6..e8dcd4c15 100644 --- a/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs +++ b/src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobStatus.cs @@ -9,9 +9,9 @@ namespace PnP.PowerShell.Commands.Lists { - [Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionBatchDeleteJobProgress")] - [OutputType(typeof(FileVersionBatchDeleteJobProgress))] - public class GetLibraryFileVersionBatchDeleteJobProgress : PnPWebCmdlet + [Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionBatchDeleteJobStatus")] + [OutputType(typeof(FileVersionBatchDeleteJobStatus))] + public class GetLibraryFileVersionBatchDeleteJobStatus : PnPWebCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] [ValidateNotNull] @@ -25,7 +25,7 @@ protected override void ExecuteCmdlet() var ret = list.GetProgressForDeleteFileVersions(); ClientContext.ExecuteQueryRetry(); - var progress = JsonSerializer.Deserialize(ret.Value); + var progress = JsonSerializer.Deserialize(ret.Value); var connectionUrl = new Uri(Connection.Url); var serverUrl = string.Concat("https://", connectionUrl.Host); progress.Url = string.Concat(serverUrl, list.RootFolder.ServerRelativeUrl); diff --git a/src/Commands/Lists/GetLibraryFileVersionExpirationReportJobProgress.cs b/src/Commands/Lists/GetLibraryFileVersionExpirationReportJobStatus.cs similarity index 84% rename from src/Commands/Lists/GetLibraryFileVersionExpirationReportJobProgress.cs rename to src/Commands/Lists/GetLibraryFileVersionExpirationReportJobStatus.cs index 9b8a9381c..ca33d0ea7 100644 --- a/src/Commands/Lists/GetLibraryFileVersionExpirationReportJobProgress.cs +++ b/src/Commands/Lists/GetLibraryFileVersionExpirationReportJobStatus.cs @@ -9,9 +9,9 @@ namespace PnP.PowerShell.Commands.Lists { - [Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionExpirationReportJobProgress")] - [OutputType(typeof(FileVersionExpirationReportJobProgress))] - public class GetLibraryFileVersionExpirationReportJobProgress : PnPWebCmdlet + [Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionExpirationReportJobStatus")] + [OutputType(typeof(FileVersionExpirationReportJobStatus))] + public class GetLibraryFileVersionExpirationReportJobStatus : PnPWebCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] [ValidateNotNull] @@ -28,7 +28,7 @@ protected override void ExecuteCmdlet() var ret = list.GetProgressForFileVersionExpirationReport(ReportUrl); ClientContext.ExecuteQueryRetry(); - var status = JsonSerializer.Deserialize(ret.Value); + var status = JsonSerializer.Deserialize(ret.Value); status.Url = list.RootFolder.ServerRelativeUrl; status.ReportUrl = ReportUrl; diff --git a/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobStatus.cs similarity index 98% rename from src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs rename to src/Commands/Model/SharePoint/FileVersionBatchDeleteJobStatus.cs index ed00b0786..3cf32bb34 100644 --- a/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobProgress.cs +++ b/src/Commands/Model/SharePoint/FileVersionBatchDeleteJobStatus.cs @@ -10,7 +10,7 @@ namespace PnP.PowerShell.Commands.Model.SharePoint /// /// The progress for the request that batch delete file versions /// - public class FileVersionBatchDeleteJobProgress + public class FileVersionBatchDeleteJobStatus { /// /// Site/Library Url diff --git a/src/Commands/Model/SharePoint/FileVersionExpirationReportJobProgress.cs b/src/Commands/Model/SharePoint/FileVersionExpirationReportJobStatus.cs similarity index 94% rename from src/Commands/Model/SharePoint/FileVersionExpirationReportJobProgress.cs rename to src/Commands/Model/SharePoint/FileVersionExpirationReportJobStatus.cs index c4eea7baa..2d31e73f1 100644 --- a/src/Commands/Model/SharePoint/FileVersionExpirationReportJobProgress.cs +++ b/src/Commands/Model/SharePoint/FileVersionExpirationReportJobStatus.cs @@ -5,7 +5,7 @@ namespace PnP.PowerShell.Commands.Model.SharePoint /// /// The progress for generating the file version expiration report. /// - public class FileVersionExpirationReportJobProgress + public class FileVersionExpirationReportJobStatus { /// /// The URL to the site or library that the report is for diff --git a/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs b/src/Commands/Model/SharePoint/SetVersionPolicyStatus.cs similarity index 98% rename from src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs rename to src/Commands/Model/SharePoint/SetVersionPolicyStatus.cs index f587ca6c3..d2c485fc6 100644 --- a/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs +++ b/src/Commands/Model/SharePoint/SetVersionPolicyStatus.cs @@ -10,7 +10,7 @@ namespace PnP.PowerShell.Commands.Model.SharePoint /// /// The progress for the request that settting version policy for existing document libraries of the site /// - public class SetVersionPolicyProgress + public class SetVersionPolicyStatus { /// /// Site Url diff --git a/src/Commands/Site/GetSetVersionPolicyProgress.cs b/src/Commands/Site/GetSetVersionPolicyStatus.cs similarity index 85% rename from src/Commands/Site/GetSetVersionPolicyProgress.cs rename to src/Commands/Site/GetSetVersionPolicyStatus.cs index 56987b645..80dad3c3c 100644 --- a/src/Commands/Site/GetSetVersionPolicyProgress.cs +++ b/src/Commands/Site/GetSetVersionPolicyStatus.cs @@ -8,9 +8,9 @@ namespace PnP.PowerShell.Commands.Site { - [Cmdlet(VerbsCommon.Get, "PnPSiteVersionPolicyProgress")] - [OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyProgress))] - public class GetSetVersionPolicyProgress : PnPSharePointCmdlet + [Cmdlet(VerbsCommon.Get, "PnPSiteVersionPolicyStatus")] + [OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyStatus))] + public class GetSetVersionPolicyStatus : PnPSharePointCmdlet { protected override void ExecuteCmdlet() { @@ -19,7 +19,7 @@ protected override void ExecuteCmdlet() var ret = site.GetProgressForSetVersionPolicyForDocLibs(); ClientContext.ExecuteQueryRetry(); - var progress = JsonSerializer.Deserialize(ret.Value); + var progress = JsonSerializer.Deserialize(ret.Value); progress.Url = site.Url; if (string.Equals(progress.LastProcessTimeInUTC, DateTime.MinValue.ToString())) diff --git a/src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs b/src/Commands/Site/GetSiteFileVersionBatchDeleteJobStatus.cs similarity index 86% rename from src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs rename to src/Commands/Site/GetSiteFileVersionBatchDeleteJobStatus.cs index 95472a6bd..36092b792 100644 --- a/src/Commands/Site/GetSiteFileVersionBatchDeleteJobProgress.cs +++ b/src/Commands/Site/GetSiteFileVersionBatchDeleteJobStatus.cs @@ -9,9 +9,9 @@ namespace PnP.PowerShell.Commands.Sites { - [Cmdlet(VerbsCommon.Get, "PnPSiteFileVersionBatchDeleteJobProgress")] - [OutputType(typeof(FileVersionBatchDeleteJobProgress))] - public class GetSiteFileVersionBatchDeleteJobProgress : PnPSharePointCmdlet + [Cmdlet(VerbsCommon.Get, "PnPSiteFileVersionBatchDeleteJobStatus")] + [OutputType(typeof(FileVersionBatchDeleteJobStatus))] + public class GetSiteFileVersionBatchDeleteJobStatus : PnPSharePointCmdlet { protected override void ExecuteCmdlet() { @@ -20,7 +20,7 @@ protected override void ExecuteCmdlet() var ret = site.GetProgressForDeleteFileVersions(); ClientContext.ExecuteQueryRetry(); - var progress = JsonSerializer.Deserialize(ret.Value); + var progress = JsonSerializer.Deserialize(ret.Value); progress.Url = site.Url; if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.DeleteOlderThanDays.ToString(), StringComparison.OrdinalIgnoreCase)) diff --git a/src/Commands/Site/GetSiteFileVersionExpirationReportJobProgress.cs b/src/Commands/Site/GetSiteFileVersionExpirationReportJobStatus.cs similarity index 81% rename from src/Commands/Site/GetSiteFileVersionExpirationReportJobProgress.cs rename to src/Commands/Site/GetSiteFileVersionExpirationReportJobStatus.cs index 8d9b490b9..ff8d4f901 100644 --- a/src/Commands/Site/GetSiteFileVersionExpirationReportJobProgress.cs +++ b/src/Commands/Site/GetSiteFileVersionExpirationReportJobStatus.cs @@ -9,9 +9,9 @@ namespace PnP.PowerShell.Commands.Sites { - [Cmdlet(VerbsCommon.Get, "PnPSiteFileVersionExpirationReportJobProgress")] - [OutputType(typeof(FileVersionExpirationReportJobProgress))] - public class GetSiteFileVersionExpirationReportJobProgress : PnPSharePointCmdlet + [Cmdlet(VerbsCommon.Get, "PnPSiteFileVersionExpirationReportJobStatus")] + [OutputType(typeof(FileVersionExpirationReportJobStatus))] + public class GetSiteFileVersionExpirationReportJobStatus : PnPSharePointCmdlet { [Parameter(Mandatory = true)] public string ReportUrl; @@ -23,7 +23,7 @@ protected override void ExecuteCmdlet() var ret = site.GetProgressForFileVersionExpirationReport(ReportUrl); ClientContext.ExecuteQueryRetry(); - var status = JsonSerializer.Deserialize(ret.Value); + var status = JsonSerializer.Deserialize(ret.Value); status.Url = site.Url; status.ReportUrl = ReportUrl; From 7c4dbad7fe160f3faf770f8222b1ce326cbf2cd9 Mon Sep 17 00:00:00 2001 From: KoenZomers Date: Mon, 8 Apr 2024 19:23:21 +0200 Subject: [PATCH 4/4] Added changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd457c25e..90a298403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added additional permissions for Graph application permission validate sets. [#3835](https://github.com/pnp/powershell/issues/3835) - Added the ability to upload entire local folders with files and optionally subfolders to SharePoint Online into 'Copy-PnPFolder' [#3850](https://github.com/pnp/powershell/pull/3850) - Added `LoopDefaultSharingLinkRole`, `DefaultShareLinkScope`, `DefaultShareLinkRole`, `LoopDefaultSharingLinkScope` and `DefaultLinkToExistingAccessReset` parameters to `Set-PnPTenant` cmdlet. [#3874](https://github.com/pnp/powershell/pull/3874) +- Added `Get-PnPLibraryFileVersionBatchDeleteJobStatus` and `Get-PnPSiteFileVersionBatchDeleteJobStatus` to check on the status of applying file based version expiration based on age on a library and site level [#3828](https://github.com/pnp/powershell/pull/3828) ### Fixed @@ -26,8 +27,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed `Get-PnPFlow` cmdlet throwing time out error due to incorrect URL used in HTTP request. [#3820](https://github.com/pnp/powershell/pull/3820) - Fixed `Copy-PnPList` cmdlet to better handle lookup columns. [#3870](https://github.com/pnp/powershell/pull/3870) +## Changed +- Renamed `Get-PnPSiteFileVersionExpirationReportJobProgress` to `Get-PnPSiteFileVersionExpirationReportJobStatus` [#3828](https://github.com/pnp/powershell/pull/3828) +- Renamed `Get-PnPSiteVersionPolicyProgress` to `Get-PnPSiteVersionPolicyStatus` [#3828](https://github.com/pnp/powershell/pull/3828) + ### Contributors +- Jenny Wu [msjennywu] - Reshmee Auckloo [reshme011] - Aimery Thomas [a1mery] - Arleta Wanat [PowershellScripts]