Skip to content

Commit eb3cf5e

Browse files
committed
Added new cmdlets
1 parent c971d0e commit eb3cf5e

File tree

7 files changed

+365
-0
lines changed

7 files changed

+365
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6363
- Added `Get-PnPTraceLog` cmdlet which allows reading from the detailed in memory logs of the PnP PowerShell cmdlet execution [#4794](https://github.com/pnp/powershell/pull/4794)
6464
- Added `-Transitive` parameter to `Get-PnPAzureADGroupMember` cmdlet to allow members of groups inside groups to be retrieved [#4799](https://github.com/pnp/powershell/pull/4799)
6565
- Added the ability to `Get-PnPPage` to return all site pages in the site by omitting the `-Identity` parameter [#4805](https://github.com/pnp/powershell/pull/4805)
66+
- Added `Copy-PnPPage`, `Move-PnPPage` and `Get-PnPPageCopyProgress` cmdlets to allow for copying and moving site pages between sites
6667

6768
### Changed
6869

documentation/Copy-PnPPage.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
title: Copy-PnPPage
4+
schema: 2.0.0
5+
applicable: SharePoint Online
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
online version: https://pnp.github.io/powershell/cmdlets/Copy-PnPPage.html
8+
---
9+
10+
# Copy-PnPPage
11+
12+
## SYNOPSIS
13+
Allows a site page to be moved from one site to another site.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Copy-PnPPage -SourceSite <SPOSitePipeBind> -DestinationSite <SPOSitePipeBind> -PageName <String>
19+
```
20+
21+
## DESCRIPTION
22+
This command allows a site page to be moved from one site to another site. The source and destination sites can be specified using the -SourceSite and -DestinationSite parameters, respectively. The page to be moved is specified using the -PageName parameter.
23+
24+
Use [Get-PnPPageCopyProgress](Get-PnPPageCopyProgress.md) to check the progress of the page copy operation.
25+
26+
Question: Will SharePoint pages retain their version history after the move?
27+
Answer: Currently, only the latest published version will be transferred.
28+
29+
Question: Can recipients of SharePoint pages I shared with continue to access them after the move?
30+
Answer: All permissions will be removed once the pages are moved.
31+
32+
## EXAMPLES
33+
34+
### EXAMPLE 1
35+
```powershell
36+
Copy-PnPPage -SourceSite https://tenant.sharepoint.com/sites/site1 -DestinationSite https://tenant.sharepoint.com -PageName "FAQ.aspx"
37+
```
38+
39+
Moves the page named 'FAQ.aspx' from the site 'site1' to the root site of the tenant.
40+
41+
## PARAMETERS
42+
43+
### -Connection
44+
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.
45+
46+
```yaml
47+
Type: PnPConnection
48+
Parameter Sets: (All)
49+
50+
Required: False
51+
Position: Named
52+
Default value: None
53+
Accept pipeline input: False
54+
Accept wildcard characters: False
55+
```
56+
57+
### -DestinationSite
58+
The destination site to which the page should be moved. This can be specified as a URL or a site object.
59+
60+
```yaml
61+
Type: SPOSitePipeBind
62+
Parameter Sets: (All)
63+
64+
Required: True
65+
Position: 0
66+
Default value: None
67+
Accept pipeline input: False
68+
Accept wildcard characters: False
69+
```
70+
71+
### -PageName
72+
The name of the page to be moved.
73+
74+
```yaml
75+
Type: String
76+
Parameter Sets: (All)
77+
78+
Required: False
79+
Default value: None
80+
Accept pipeline input: False
81+
Accept wildcard characters: False
82+
```
83+
84+
### -SourceSite
85+
The source site from which the page will be moved. This can be specified as a URL or a site object.
86+
87+
```yaml
88+
Type: SPOSitePipeBind
89+
Parameter Sets: (All)
90+
91+
Required: True
92+
Default value: None
93+
Accept pipeline input: True (ByValue)
94+
Accept wildcard characters: False
95+
```
96+
97+
## RELATED LINKS
98+
99+
[SharePoint Online Management Shell equivallent](https://learn.microsoft.com/powershell/module/sharepoint-online/copy-spopersonalsitepage)
100+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
title: Get-PnPPageCopyProgress
4+
schema: 2.0.0
5+
applicable: SharePoint Online
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPageCopyProgress.html
8+
---
9+
10+
# Get-PnPPageCopyProgress
11+
12+
## SYNOPSIS
13+
Allows checking the progress of a site page move or copy operation from one site to another site.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Get-PnPPageCopyProgress -DestinationSite <SPOSitePipeBind> -WorkItemId <Guid>
19+
```
20+
21+
## DESCRIPTION
22+
This command allows checking the progress of a site page move or copy operation from one site to another site. The destination site can be specified using the -DestinationSite parameter, and the work item ID can be specified using the -WorkItemId parameter.
23+
24+
## EXAMPLES
25+
26+
### EXAMPLE 1
27+
```powershell
28+
Get-PnPPageCopyProgress -DestinationSite https://tenant.sharepoint.com -WorkItemId 12345678-1234-1234-1234-123456789012
29+
```
30+
31+
Retrieves the progress of the page copy operation with the specified work item ID to the destination site.
32+
33+
## PARAMETERS
34+
35+
### -Connection
36+
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.
37+
38+
```yaml
39+
Type: PnPConnection
40+
Parameter Sets: (All)
41+
42+
Required: False
43+
Position: Named
44+
Default value: None
45+
Accept pipeline input: False
46+
Accept wildcard characters: False
47+
```
48+
49+
### -DestinationSite
50+
The destination site to which the page is being moved or copied. This can be specified as a URL or a site object.
51+
52+
```yaml
53+
Type: SPOSitePipeBind
54+
Parameter Sets: (All)
55+
56+
Required: True
57+
Position: 0
58+
Default value: None
59+
Accept pipeline input: False
60+
Accept wildcard characters: False
61+
```
62+
63+
### -WorkItemId
64+
The work item ID of the page copy operation. This is a GUID that uniquely identifies the copy operation and is returned when the copy or move operation is initiated using [Copy-PnPPage](Copy-PnPPage.md) and [Move-PnPPage](Move-PnPPage.md).
65+
66+
```yaml
67+
Type: Guid
68+
Parameter Sets: (All)
69+
70+
Required: True
71+
Default value: None
72+
Accept pipeline input: False
73+
Accept wildcard characters: False
74+
```
75+
76+
## RELATED LINKS
77+
78+
[SharePoint Online Management Shell equivallent](https://learn.microsoft.com/powershell/module/sharepoint-online/get-spopersonalsitepagecopyprogress)
79+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

documentation/Move-PnPPage.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
title: Move-PnPPage
4+
schema: 2.0.0
5+
applicable: SharePoint Online
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
online version: https://pnp.github.io/powershell/cmdlets/Move-PnPPage.html
8+
---
9+
10+
# Move-PnPPage
11+
12+
## SYNOPSIS
13+
Allows a site page to be moved from one site to another site.
14+
15+
## SYNTAX
16+
17+
```powershell
18+
Move-PnPPage -SourceSite <SPOSitePipeBind> -DestinationSite <SPOSitePipeBind> -PageName <String>
19+
```
20+
21+
## DESCRIPTION
22+
This command allows a site page to be moved from one site to another site. The source and destination sites can be specified using the -SourceSite and -DestinationSite parameters, respectively. The page to be moved is specified using the -PageName parameter.
23+
24+
Use [Get-PnPPageCopyProgress](Get-PnPPageCopyProgress.md) to check the progress of the page move operation.
25+
26+
Question: Will SharePoint pages retain their version history after the move?
27+
Answer: Currently, only the latest published version will be transferred.
28+
29+
Question: Can recipients of SharePoint pages I shared with continue to access them after the move?
30+
Answer: All permissions will be removed once the pages are moved.
31+
32+
## EXAMPLES
33+
34+
### EXAMPLE 1
35+
```powershell
36+
Move-PnPPage -SourceSite https://tenant.sharepoint.com/sites/site1 -DestinationSite https://tenant.sharepoint.com -PageName "FAQ.aspx"
37+
```
38+
39+
Moves the page named 'FAQ.aspx' from the site 'site1' to the root site of the tenant.
40+
41+
## PARAMETERS
42+
43+
### -Connection
44+
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.
45+
46+
```yaml
47+
Type: PnPConnection
48+
Parameter Sets: (All)
49+
50+
Required: False
51+
Position: Named
52+
Default value: None
53+
Accept pipeline input: False
54+
Accept wildcard characters: False
55+
```
56+
57+
### -DestinationSite
58+
The destination site to which the page should be moved. This can be specified as a URL or a site object.
59+
60+
```yaml
61+
Type: SPOSitePipeBind
62+
Parameter Sets: (All)
63+
64+
Required: True
65+
Position: 0
66+
Default value: None
67+
Accept pipeline input: False
68+
Accept wildcard characters: False
69+
```
70+
71+
### -PageName
72+
The name of the page to be moved.
73+
74+
```yaml
75+
Type: String
76+
Parameter Sets: (All)
77+
78+
Required: False
79+
Default value: None
80+
Accept pipeline input: False
81+
Accept wildcard characters: False
82+
```
83+
84+
### -SourceSite
85+
The source site from which the page will be moved. This can be specified as a URL or a site object.
86+
87+
```yaml
88+
Type: SPOSitePipeBind
89+
Parameter Sets: (All)
90+
91+
Required: True
92+
Default value: None
93+
Accept pipeline input: True (ByValue)
94+
Accept wildcard characters: False
95+
```
96+
97+
## RELATED LINKS
98+
99+
[SharePoint Online Management Shell equivallent](https://learn.microsoft.com/powershell/module/sharepoint-online/copy-spopersonalsitepage)
100+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

src/Commands/Admin/CopyPage.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Management.Automation;
2+
using Microsoft.Online.SharePoint.TenantAdministration;
3+
using Microsoft.SharePoint.Client;
4+
using PnP.PowerShell.Commands.Base;
5+
using PnP.PowerShell.Commands.Base.PipeBinds;
6+
7+
namespace PnP.PowerShell.Commands
8+
{
9+
[Cmdlet(VerbsCommon.Copy, "PnPPage")]
10+
[OutputType(typeof(SPSitePageCopyJobProgress))]
11+
public class CopyPage : PnPSharePointOnlineAdminCmdlet
12+
{
13+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
14+
public SPOSitePipeBind SourceSite;
15+
16+
[Parameter(Mandatory = true)]
17+
public SPOSitePipeBind DestinationSite;
18+
19+
[Parameter(Mandatory = false)]
20+
public string PageName;
21+
22+
protected override void ExecuteCmdlet()
23+
{
24+
var result = Tenant.CopyPersonalSitePage(SourceSite.Url, DestinationSite.Url, PageName, false);
25+
AdminContext.ExecuteQueryRetry();
26+
WriteObject(result.Value);
27+
}
28+
}
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Management.Automation;
3+
using Microsoft.Online.SharePoint.TenantAdministration;
4+
using Microsoft.SharePoint.Client;
5+
using PnP.PowerShell.Commands.Base;
6+
using PnP.PowerShell.Commands.Base.PipeBinds;
7+
8+
namespace PnP.PowerShell.Commands
9+
{
10+
[Cmdlet(VerbsCommon.Get, "PnPPageCopyProgress")]
11+
[OutputType(typeof(SPSitePageCopyJobProgress))]
12+
public class GetPageCopyProgress : PnPSharePointOnlineAdminCmdlet
13+
{
14+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
15+
public SPOSitePipeBind DestinationSite;
16+
17+
[Parameter(Mandatory = true)]
18+
public Guid WorkItemId;
19+
20+
protected override void ExecuteCmdlet()
21+
{
22+
var result = Tenant.GetSitePageCopyJobProgress(DestinationSite.Url, WorkItemId);
23+
AdminContext.ExecuteQueryRetry();
24+
WriteObject(result.Value);
25+
}
26+
}
27+
}

src/Commands/Admin/MovePage.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Management.Automation;
2+
using Microsoft.Online.SharePoint.TenantAdministration;
3+
using Microsoft.SharePoint.Client;
4+
using PnP.PowerShell.Commands.Base;
5+
using PnP.PowerShell.Commands.Base.PipeBinds;
6+
7+
namespace PnP.PowerShell.Commands
8+
{
9+
[Cmdlet(VerbsCommon.Move, "PnPPage")]
10+
[OutputType(typeof(SPSitePageCopyJobProgress))]
11+
public class MovePage : PnPSharePointOnlineAdminCmdlet
12+
{
13+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
14+
public SPOSitePipeBind SourceSite;
15+
16+
[Parameter(Mandatory = true)]
17+
public SPOSitePipeBind DestinationSite;
18+
19+
[Parameter(Mandatory = false)]
20+
public string PageName;
21+
22+
protected override void ExecuteCmdlet()
23+
{
24+
var result = Tenant.CopyPersonalSitePage(SourceSite.Url, DestinationSite.Url, PageName, true);
25+
AdminContext.ExecuteQueryRetry();
26+
WriteObject(result.Value);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)