diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e9dc8730..e7fa14d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `RequestFilesLinkEnabled` and `RequestFilesLinkExpirationInDays` to the output of `Get-PnPSite` [#3557](https://github.com/pnp/powershell/pull/3557) - Added `CoreRequestFilesLinkEnabled`, `CoreRequestFilesLinkExpirationInDays`, `OneDriveRequestFilesLinkEnabled`, `OneDriveRequestFilesLinkExpirationInDays`, `BusinessConnectivityServiceDisabled` to the output of `Get-PnPTenant` [#3557](https://github.com/pnp/powershell/pull/3557) - Added `-BusinessConnectivityServiceDisabled` parameter to `Set-PnPTenant` cmdlt to allow disabling the Business Connectivity Service [#3562](https://github.com/pnp/powershell/pull/3562) +- Added `Get-PnPSiteSetVersionPolicyProgress` cmdlet which allows for getting the progress of setting a version policy for existing document libraries on a site [#3564](https://github.com/pnp/powershell/pull/3564) ### Fixed diff --git a/documentation/Get-PnPSiteSetVersionPolicyProgress.md b/documentation/Get-PnPSiteSetVersionPolicyProgress.md new file mode 100644 index 000000000..ae8903a0f --- /dev/null +++ b/documentation/Get-PnPSiteSetVersionPolicyProgress.md @@ -0,0 +1,52 @@ +--- +Module Name: PnP.PowerShell +schema: 2.0.0 +applicable: SharePoint Online +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteSetVersionPolicyProgress.html +external help file: PnP.PowerShell.dll-Help.xml +title: Get-PnPSiteSetVersionPolicyProgress +--- + +# Get-PnPSiteSetVersionPolicyProgress + +## SYNOPSIS +Get the progress of setting version policy for existing document libraries on the site. + +## SYNTAX + +```powershell +Get-PnPSiteSetVersionPolicyProgress [-Connection ] +``` + +## DESCRIPTION +This cmdlet allows retrieval of the progress of setting version policy for existing document libraries on the site. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-PnPSiteSetVersionPolicyProgress +``` + +Returns the progress of setting version policy for existing document libraries 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) +[Microsoft Docs documentation](https://learn.microsoft.com/sharepoint/dev/solution-guidance/modern-experience-site-classification#programmatically-read-the-classification-of-a-site) \ No newline at end of file diff --git a/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs b/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs new file mode 100644 index 000000000..0bb6d3f01 --- /dev/null +++ b/src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs @@ -0,0 +1,75 @@ +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 SetVersionPolicyProgress + { + /// + /// 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 lists processed count + /// + public string ListsProcessedInTotal { get; set; } + + /// + /// The lists failed to process count + /// + public string ListsFailedInTotal { get; set; } + + /// + /// Set version policy as AutoExpiration or not + /// + public string EnableAutoTrim { 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 new file mode 100644 index 000000000..036e6e1d0 --- /dev/null +++ b/src/Commands/Site/GetSetVersionPolicyProgress.cs @@ -0,0 +1,39 @@ +using Microsoft.SharePoint.Client; + +using System; +using System.Linq.Expressions; +using System.Management.Automation; +using System.Text.Json; +using PnP.PowerShell.Commands.Model.SharePoint; + +namespace PnP.PowerShell.Commands.Site +{ + [Cmdlet(VerbsCommon.Get, "PnPSiteSetVersionPolicyProgress")] + [OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyProgress))] + public class GetSetVersionPolicyProgress : PnPSharePointCmdlet + { + protected override void ExecuteCmdlet() + { + ClientContext.Load(ClientContext.Site, s => s.Url); + var site = ClientContext.Site; + var ret = site.GetProgressForSetVersionPolicyForDocLibs(); + ClientContext.ExecuteQueryRetry(); + + var progress = JsonSerializer.Deserialize(ret.Value); + progress.Url = site.Url; + + 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); + } + } +} +