Skip to content

Commit de3cb64

Browse files
Add Set-PnPFolderArchiveState cmdlet and related documentation (#5284)
* Add Set-PnPFolderArchiveState cmdlet and related documentation * Update CHANGELOG.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 396989e commit de3cb64

5 files changed

Lines changed: 433 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3434
- Add optional parameter `-Force` to cmdlet `Remove-PnPSiteGroup`. [#5214](https://github.com/pnp/powershell/pull/5214)
3535
- `Invoke-PnPGraphMethod` cmdlet now supports relative URLs. [#5255](https://github.com/pnp/powershell/pull/5255)
3636
- Added `Set-PnPFileArchiveState` cmdlet to archive and reactivate SharePoint files through the Microsoft Graph beta archive APIs. [#5283](https://github.com/pnp/powershell/pull/5283)
37+
- Added `Set-PnPFolderArchiveState` cmdlet to archive and reactivate SharePoint folders through the Microsoft Graph beta archive APIs. [#5283](https://github.com/pnp/powershell/pull/5283)
3738

3839
### Changed
3940
- Improved `Get-PnPTerm` cmdlet to show a better error message. [#4933](https://github.com/pnp/powershell/pull/4933)
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
schema: 2.0.0
4+
applicable: SharePoint Online
5+
online version: https://pnp.github.io/powershell/cmdlets/Set-PnPFolderArchiveState.html
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
title: Set-PnPFolderArchiveState
8+
---
9+
10+
# Set-PnPFolderArchiveState
11+
12+
## SYNOPSIS
13+
14+
**Required Permissions**
15+
16+
* Microsoft Graph API (Delegated only): Files.ReadWrite, Files.Read, Files.Read.All, or Files.ReadWrite.All to archive folders, and Files.Read or Files.Read.All to reactivate folders
17+
18+
Archives or reactivates a folder in a document library in the current web by using the Microsoft Graph beta archive APIs.
19+
20+
## OUTPUTS
21+
22+
### PnP.PowerShell.Commands.Model.SharePoint.FolderArchiveStateResult
23+
24+
Returns a result object containing the folder name, server relative URL, requested archive state, and the monitor URL returned by Microsoft Graph.
25+
26+
## SYNTAX
27+
28+
```powershell
29+
Set-PnPFolderArchiveState -Identity <FolderPipeBind> -ArchiveState <FolderArchiveState> [-Force] [-Connection <PnPConnection>]
30+
```
31+
32+
## DESCRIPTION
33+
34+
The Set-PnPFolderArchiveState cmdlet archives or reactivates a folder in a document library in the current web through the Microsoft Graph beta driveItem archive endpoints.
35+
36+
Folder archive and reactivation are asynchronous operations. Microsoft Graph requires the Prefer: respond-async header for folders and returns a monitor URL in the Location header so progress can be tracked until completion.
37+
38+
Only folders in document libraries in the current web are supported.
39+
40+
## EXAMPLES
41+
42+
### Example 1
43+
```powershell
44+
Set-PnPFolderArchiveState -Identity "/sites/Marketing/Shared Documents/QuarterlyReports" -ArchiveState Archived
45+
```
46+
47+
This example archives the specified folder and returns the monitor URL for the asynchronous operation.
48+
49+
### Example 2
50+
```powershell
51+
Set-PnPFolderArchiveState -Identity "/sites/Marketing/Shared Documents/QuarterlyReports" -ArchiveState Active
52+
```
53+
54+
This example reactivates the specified folder and returns the monitor URL for the asynchronous operation.
55+
56+
### Example 3
57+
```powershell
58+
Get-PnPFolder -Url "/sites/Marketing/Shared Documents/QuarterlyReports" | Set-PnPFolderArchiveState -ArchiveState Archived -Force
59+
```
60+
61+
This example archives the specified folder coming from the pipeline without prompting for confirmation.
62+
63+
## PARAMETERS
64+
65+
### -Identity
66+
Specifies the server relative URL, Folder instance or Id of the folder in a document library in the current web for which to change the archive state.
67+
68+
```yaml
69+
Type: FolderPipeBind
70+
Parameter Sets: (All)
71+
72+
Required: True
73+
Position: 0
74+
Default value: None
75+
Accept pipeline input: True
76+
Accept wildcard characters: False
77+
```
78+
79+
### -ArchiveState
80+
Specifies the desired archive state of the folder. Valid values are Archived and Active.
81+
82+
```yaml
83+
Type: FolderArchiveState
84+
Parameter Sets: (All)
85+
86+
Required: True
87+
Position: 1
88+
Default value: None
89+
Accept pipeline input: False
90+
Accept wildcard characters: False
91+
```
92+
93+
### -Force
94+
If provided, no confirmation will be asked before changing the archive state.
95+
96+
```yaml
97+
Type: SwitchParameter
98+
Parameter Sets: (All)
99+
100+
Required: False
101+
Position: Named
102+
Default value: None
103+
Accept pipeline input: False
104+
Accept wildcard characters: False
105+
```
106+
107+
## RELATED LINKS
108+
109+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
110+
[Archive driveItem through Microsoft Graph beta](https://learn.microsoft.com/en-us/graph/api/driveitem-archive?view=graph-rest-beta&tabs=http)
111+
[Unarchive driveItem through Microsoft Graph beta](https://learn.microsoft.com/en-us/graph/api/driveitem-unarchive?view=graph-rest-beta&tabs=http)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace PnP.PowerShell.Commands.Enums
2+
{
3+
public enum FolderArchiveState
4+
{
5+
Archived,
6+
Active
7+
}
8+
}

0 commit comments

Comments
 (0)