Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FileVersion] Add command to get progress for set version policy #3564

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[FileVersion] Add command to get progress for set version policy
  • Loading branch information
jennywu committed Nov 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit f281a6ac392760f898248894217e298441dc2efb
52 changes: 52 additions & 0 deletions documentation/Get-PnPSiteSetVersionPolicyProgress.md
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)
75 changes: 75 additions & 0 deletions src/Commands/Model/SharePoint/SetVersionPolicyProgress.cs
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; }
}
}
39 changes: 39 additions & 0 deletions src/Commands/Site/GetSetVersionPolicyProgress.cs
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);
}
}
}