Skip to content

Commit

Permalink
Merge pull request #3564 from msjennywu/AddCommandToGetProgressForSet…
Browse files Browse the repository at this point in the history
…VersionPolicy

[FileVersion] Add command to get progress for set version policy
  • Loading branch information
KoenZomers authored Nov 14, 2023
2 parents 7295d2c + 0f87366 commit 52302fc
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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);
}
}
}

0 comments on commit 52302fc

Please sign in to comment.