-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3564 from msjennywu/AddCommandToGetProgressForSet…
…VersionPolicy [FileVersion] Add command to get progress for set version policy
- Loading branch information
Showing
4 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <PnPConnection>] | ||
``` | ||
|
||
## 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// The progress for the request that settting version policy for existing document libraries of the site | ||
/// </summary> | ||
public class SetVersionPolicyProgress | ||
{ | ||
/// <summary> | ||
/// Site Url | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// The workitem Id related to the request | ||
/// </summary> | ||
public string WorkItemId { get; set; } | ||
|
||
/// <summary> | ||
/// The request status | ||
/// </summary> | ||
public string Status { get; set; } | ||
|
||
/// <summary> | ||
/// The UTC time user sent the request | ||
/// </summary> | ||
public string RequestTimeInUTC { get; set; } | ||
|
||
/// <summary> | ||
/// The UTC time the server last processed the request | ||
/// </summary> | ||
public string LastProcessTimeInUTC { get; set; } | ||
|
||
/// <summary> | ||
/// The UTC time the request completes | ||
/// </summary> | ||
public string CompleteTimeInUTC { get; set; } | ||
|
||
/// <summary> | ||
/// The lists processed count | ||
/// </summary> | ||
public string ListsProcessedInTotal { get; set; } | ||
|
||
/// <summary> | ||
/// The lists failed to process count | ||
/// </summary> | ||
public string ListsFailedInTotal { get; set; } | ||
|
||
/// <summary> | ||
/// Set version policy as AutoExpiration or not | ||
/// </summary> | ||
public string EnableAutoTrim { get; set; } | ||
|
||
/// <summary> | ||
/// The time limit if the version policy is ExpireAfter | ||
/// </summary> | ||
public string ExpireAfterDays { get; set; } | ||
|
||
/// <summary> | ||
/// MajorVersionLimit for the versions | ||
/// </summary> | ||
public string MajorVersionLimit { get; set; } | ||
|
||
/// <summary> | ||
/// MajorWithMinorVersionsLimit for the versions | ||
/// if minor version is enabled | ||
/// </summary> | ||
public string MajorWithMinorVersionsLimit { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SetVersionPolicyProgress>(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); | ||
} | ||
} | ||
} | ||
|