-
Notifications
You must be signed in to change notification settings - Fork 360
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 #3086 from mromiszewski/version-history
Added cmdlets for list item version history
- Loading branch information
Showing
9 changed files
with
581 additions
and
4 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
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) |
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,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) |
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,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) |
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,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; } | ||
} |
Oops, something went wrong.