Skip to content

Commit 52302fc

Browse files
authored
Merge pull request #3564 from msjennywu/AddCommandToGetProgressForSetVersionPolicy
[FileVersion] Add command to get progress for set version policy
2 parents 7295d2c + 0f87366 commit 52302fc

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4747
- Added `RequestFilesLinkEnabled` and `RequestFilesLinkExpirationInDays` to the output of `Get-PnPSite` [#3557](https://github.com/pnp/powershell/pull/3557)
4848
- Added `CoreRequestFilesLinkEnabled`, `CoreRequestFilesLinkExpirationInDays`, `OneDriveRequestFilesLinkEnabled`, `OneDriveRequestFilesLinkExpirationInDays`, `BusinessConnectivityServiceDisabled` to the output of `Get-PnPTenant` [#3557](https://github.com/pnp/powershell/pull/3557)
4949
- Added `-BusinessConnectivityServiceDisabled` parameter to `Set-PnPTenant` cmdlt to allow disabling the Business Connectivity Service [#3562](https://github.com/pnp/powershell/pull/3562)
50+
- 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)
5051

5152
### Fixed
5253

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
schema: 2.0.0
4+
applicable: SharePoint Online
5+
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteSetVersionPolicyProgress.html
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
title: Get-PnPSiteSetVersionPolicyProgress
8+
---
9+
10+
# Get-PnPSiteSetVersionPolicyProgress
11+
12+
## SYNOPSIS
13+
Get the progress of setting version policy for existing document libraries on the site.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Get-PnPSiteSetVersionPolicyProgress [-Connection <PnPConnection>]
19+
```
20+
21+
## DESCRIPTION
22+
This cmdlet allows retrieval of the progress of setting version policy for existing document libraries on the site.
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```powershell
28+
Get-PnPSiteSetVersionPolicyProgress
29+
```
30+
31+
Returns the progress of setting version policy for existing document libraries on the site.
32+
33+
## PARAMETERS
34+
35+
### -Connection
36+
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.
37+
38+
```yaml
39+
Type: PnPConnection
40+
Parameter Sets: (All)
41+
42+
Required: False
43+
Position: Named
44+
Default value: None
45+
Accept pipeline input: False
46+
Accept wildcard characters: False
47+
```
48+
49+
## RELATED LINKS
50+
51+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
52+
[Microsoft Docs documentation](https://learn.microsoft.com/sharepoint/dev/solution-guidance/modern-experience-site-classification#programmatically-read-the-classification-of-a-site)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace PnP.PowerShell.Commands.Model.SharePoint
8+
{
9+
/// <summary>
10+
/// The progress for the request that settting version policy for existing document libraries of the site
11+
/// </summary>
12+
public class SetVersionPolicyProgress
13+
{
14+
/// <summary>
15+
/// Site Url
16+
/// </summary>
17+
public string Url { get; set; }
18+
19+
/// <summary>
20+
/// The workitem Id related to the request
21+
/// </summary>
22+
public string WorkItemId { get; set; }
23+
24+
/// <summary>
25+
/// The request status
26+
/// </summary>
27+
public string Status { get; set; }
28+
29+
/// <summary>
30+
/// The UTC time user sent the request
31+
/// </summary>
32+
public string RequestTimeInUTC { get; set; }
33+
34+
/// <summary>
35+
/// The UTC time the server last processed the request
36+
/// </summary>
37+
public string LastProcessTimeInUTC { get; set; }
38+
39+
/// <summary>
40+
/// The UTC time the request completes
41+
/// </summary>
42+
public string CompleteTimeInUTC { get; set; }
43+
44+
/// <summary>
45+
/// The lists processed count
46+
/// </summary>
47+
public string ListsProcessedInTotal { get; set; }
48+
49+
/// <summary>
50+
/// The lists failed to process count
51+
/// </summary>
52+
public string ListsFailedInTotal { get; set; }
53+
54+
/// <summary>
55+
/// Set version policy as AutoExpiration or not
56+
/// </summary>
57+
public string EnableAutoTrim { get; set; }
58+
59+
/// <summary>
60+
/// The time limit if the version policy is ExpireAfter
61+
/// </summary>
62+
public string ExpireAfterDays { get; set; }
63+
64+
/// <summary>
65+
/// MajorVersionLimit for the versions
66+
/// </summary>
67+
public string MajorVersionLimit { get; set; }
68+
69+
/// <summary>
70+
/// MajorWithMinorVersionsLimit for the versions
71+
/// if minor version is enabled
72+
/// </summary>
73+
public string MajorWithMinorVersionsLimit { get; set; }
74+
}
75+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.SharePoint.Client;
2+
3+
using System;
4+
using System.Linq.Expressions;
5+
using System.Management.Automation;
6+
using System.Text.Json;
7+
using PnP.PowerShell.Commands.Model.SharePoint;
8+
9+
namespace PnP.PowerShell.Commands.Site
10+
{
11+
[Cmdlet(VerbsCommon.Get, "PnPSiteSetVersionPolicyProgress")]
12+
[OutputType(typeof(PnP.PowerShell.Commands.Model.SharePoint.SetVersionPolicyProgress))]
13+
public class GetSetVersionPolicyProgress : PnPSharePointCmdlet
14+
{
15+
protected override void ExecuteCmdlet()
16+
{
17+
ClientContext.Load(ClientContext.Site, s => s.Url);
18+
var site = ClientContext.Site;
19+
var ret = site.GetProgressForSetVersionPolicyForDocLibs();
20+
ClientContext.ExecuteQueryRetry();
21+
22+
var progress = JsonSerializer.Deserialize<SetVersionPolicyProgress>(ret.Value);
23+
progress.Url = site.Url;
24+
25+
if (string.Equals(progress.LastProcessTimeInUTC, DateTime.MinValue.ToString()))
26+
{
27+
progress.LastProcessTimeInUTC = string.Empty;
28+
}
29+
30+
if (string.Equals(progress.CompleteTimeInUTC, DateTime.MinValue.ToString()))
31+
{
32+
progress.CompleteTimeInUTC = string.Empty;
33+
}
34+
35+
WriteObject(progress);
36+
}
37+
}
38+
}
39+

0 commit comments

Comments
 (0)