-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FileVersion] Add and update batch delete cmdlets
- Loading branch information
jennywu
committed
Mar 13, 2024
1 parent
80fea6c
commit 00bb7d2
Showing
12 changed files
with
558 additions
and
107 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
documentation/Get-PnPLibraryFileVersionBatchDeleteJobProgress.md
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,65 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPLibraryFileVersionBatchDeleteJobProgress.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPLibraryFileVersionBatchDeleteJobProgress | ||
--- | ||
|
||
# Get-PnPLibraryFileVersionBatchDeleteJobProgress | ||
|
||
## SYNOPSIS | ||
Get the progress of deleting existing file versions on the document library. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity <ListPipeBind> [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
This cmdlet allows retrieval of the progress of deleting existing file versions on the document library. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPLibraryFileVersionBatchDeleteJobProgress -Identity "Documents" | ||
``` | ||
|
||
Returns the progress of deleting existing file versions on the document library. | ||
|
||
## PARAMETERS | ||
|
||
### -Identity | ||
The ID, name or Url (Lists/MyList) of the document library to perform the trimming on. | ||
|
||
```yaml | ||
Type: ListPipeBind | ||
Parameter Sets: (All) | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
### -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) |
51 changes: 51 additions & 0 deletions
51
documentation/Get-PnPSiteFileVersionBatchDeleteJobProgress.md
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,51 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteFileVersionBatchDeleteJobProgress.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPSiteFileVersionBatchDeleteJobProgress | ||
--- | ||
|
||
# Get-PnPSiteFileVersionBatchDeleteJobProgress | ||
|
||
## SYNOPSIS | ||
Get the progress of deleting existing file versions on the site. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPSiteFileVersionBatchDeleteJobProgress [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
This cmdlet allows retrieval of the progress of deleting existing file versions on the site. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPSiteFileVersionBatchDeleteJobProgress | ||
``` | ||
|
||
Returns the progress of deleting existing file versions 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) |
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
58 changes: 58 additions & 0 deletions
58
src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs
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,58 @@ | ||
using Microsoft.SharePoint.Client; | ||
|
||
using PnP.Framework.Utilities; | ||
using PnP.PowerShell.Commands.Base.PipeBinds; | ||
using PnP.PowerShell.Commands.Model.SharePoint; | ||
using System; | ||
using System.Management.Automation; | ||
using System.Text.Json; | ||
|
||
namespace PnP.PowerShell.Commands.Lists | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPLibraryFileVersionBatchDeleteJobProgress")] | ||
[OutputType(typeof(FileVersionBatchDeleteJobProgress))] | ||
public class GetLibraryFileVersionBatchDeleteJobProgress : PnPWebCmdlet | ||
{ | ||
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] | ||
[ValidateNotNull] | ||
public ListPipeBind Identity; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var list = Identity.GetList(CurrentWeb); | ||
if (list != null) | ||
{ | ||
var ret = list.GetProgressForDeleteFileVersions(); | ||
Check failure on line 25 in src/Commands/Lists/GetLibraryFileVersionBatchDeleteJobProgress.cs GitHub Actions / build_dev_branch
|
||
ClientContext.ExecuteQueryRetry(); | ||
|
||
var progress = JsonSerializer.Deserialize<FileVersionBatchDeleteJobProgress>(ret.Value); | ||
var connectionUrl = new Uri(Connection.Url); | ||
var serverUrl = string.Concat("https://", connectionUrl.Host); | ||
progress.Url = string.Concat(serverUrl, list.RootFolder.ServerRelativeUrl); | ||
|
||
if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.DeleteOlderThanDays.ToString(), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
progress.DeleteOlderThan = string.Empty; | ||
} | ||
|
||
if (!string.Equals(progress.BatchDeleteMode, FileVersionBatchDeleteMode.CountLimits.ToString(), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
progress.MajorVersionLimit = string.Empty; | ||
progress.MajorWithMinorVersionsLimit = string.Empty; | ||
} | ||
|
||
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); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.