Skip to content

Commit

Permalink
Merge pull request #3086 from mromiszewski/version-history
Browse files Browse the repository at this point in the history
Added cmdlets for list item version history
  • Loading branch information
gautamdsheth authored Jun 9, 2023
2 parents 669eae0 + 2409a69 commit 63ed6d1
Show file tree
Hide file tree
Showing 9 changed files with 581 additions and 4 deletions.
93 changes: 93 additions & 0 deletions documentation/Get-PnPListItemVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
Module Name: PnP.PowerShell
title: Get-PnPListItemVersion
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPListItemVersion.html
---

# Get-PnPListItemVersion

## SYNOPSIS
Retrieves the previous versions of a list item.

## SYNTAX

```powershell
Get-PnPListItemVersion -List <ListPipeBind> -Identity <ListItemPipeBind> [-Connection <PnPConnection>]
```

## DESCRIPTION
This cmdlet retrieves the version history of a list item.

## EXAMPLES

### EXAMPLE 1
```powershell
Get-PnPListItemVersion -List "Demo List" -Identity 1
```

Retrieves the list item version history.

## PARAMETERS

### -List
The ID, Title or Url of the list.

```yaml
Type: ListPipeBind
Parameter Sets: (All)

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Identity
The ID of the listitem, or actual ListItem object.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Version
The ID or label of the version.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
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)
128 changes: 128 additions & 0 deletions documentation/Remove-PnPListItemVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
Module Name: PnP.PowerShell
title: Remove-PnPListItemVersion
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Remove-PnPListItemVersion.html
---

# Remove-PnPListItemVersion

## SYNOPSIS
Removes a specific list item version.

## SYNTAX

```powershell
Remove-PnPListItemVersion -List <ListPipeBind> -Identity <ListItemPipeBind> -Version <ListItemVersionPipeBind> [-Force] [-Verbose] [-Connection <PnPConnection>]
```

## DESCRIPTION
This cmdlet removes a specific list item version.

## EXAMPLES

### EXAMPLE 1
```powershell
Remove-PnPListItemVersion -List "Demo List" -Identity 1 -Version 512
```

Removes the list item version with Id 512.

### EXAMPLE 2
```powershell
Remove-PnPListItemVersion -List "Demo List" -Identity 1 -Version "1.0"
```

Removes the list item version with version label "1.0".

## PARAMETERS

### -List
The ID, Title or Url of the list.

```yaml
Type: ListPipeBind
Parameter Sets: (All)

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Identity
The ID of the listitem, or actual ListItem object.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Version
The ID or label of the version.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Force
If provided, no confirmation will be requested and the action will be performed.
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Verbose
When provided, additional debug statements will be shown while executing the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
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)
128 changes: 128 additions & 0 deletions documentation/Restore-PnPListItemVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
Module Name: PnP.PowerShell
title: Restore-PnPListItemVersion
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Restore-PnPListItemVersion.html
---

# Restore-PnPListItemVersion

## SYNOPSIS
Restores a specific list item version.

## SYNTAX

```powershell
Restore-PnPListItemVersion -List <ListPipeBind> -Identity <ListItemPipeBind> -Version <ListItemVersionPipeBind> [-Force] [-Verbose] [-Connection <PnPConnection>]
```

## DESCRIPTION
This cmdlet restores a specific list item version.

## EXAMPLES

### EXAMPLE 1
```powershell
Restore-PnPListItemVersion -List "Demo List" -Identity 1 -Version 512
```

Restores the list item version with Id 512.

### EXAMPLE 2
```powershell
Restore-PnPListItemVersion -List "Demo List" -Identity 1 -Version "1.0"
```

Restores the list item version with version label "1.0".

## PARAMETERS

### -List
The ID, Title or Url of the list.

```yaml
Type: ListPipeBind
Parameter Sets: (All)

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Identity
The ID of the listitem, or actual ListItem object.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Version
The ID or label of the version.
```yaml
Type: ListItemPipeBind
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Force
If provided, no confirmation will be requested and the action will be performed.
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Verbose
When provided, additional debug statements will be shown while executing the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
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)
25 changes: 25 additions & 0 deletions src/Commands/Base/PipeBinds/ListItemVersionPipeBind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace PnP.PowerShell.Commands.Base.PipeBinds;

public class ListItemVersionPipeBind
{
public ListItemVersionPipeBind(string versionLabel)
{
if (int.TryParse(versionLabel, out var id))
{
Id = id;
}
else
{
VersionLabel = versionLabel;
}
}

public ListItemVersionPipeBind(int id)
{
Id = id;
}

public int Id { get; } = -1;

public string VersionLabel { get; }
}
Loading

0 comments on commit 63ed6d1

Please sign in to comment.