Skip to content

Commit 315c14a

Browse files
gautamdshethGautam Sheth
andauthored
Refactor Export-PnPPage cmdlet to add support for returning the template as an in-memory object (#4323)
Co-authored-by: Gautam Sheth <gautam.sheth@staffbase.com>
1 parent 0306f2f commit 315c14a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

documentation/Export-PnPPage.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Exports a Client Side Page to a PnP Provisioning Template
1616

1717
```powershell
1818
Export-PnPPage [-Identity] <PagePipeBind> [-PersistBrandingFiles] [-Out <String>] [-Force]
19-
[-Configuration <ExtractConfigurationPipeBind>] [-Connection <PnPConnection>]
19+
[-Configuration <ExtractConfigurationPipeBind>] [-OutputInstance] [-Connection <PnPConnection>]
2020
2121
```
2222

@@ -141,15 +141,12 @@ Accept pipeline input: False
141141
Accept wildcard characters: False
142142
```
143143
144-
145-
146-
### -WhatIf
147-
Shows what would happen if the cmdlet runs. The cmdlet is not run.
144+
### -OutputInstance
145+
Returns the template as an in-memory object, which is an instance of the SiteTemplate type of the PnP Core Component. It cannot be used together with the -Out parameter.
148146
149147
```yaml
150148
Type: SwitchParameter
151149
Parameter Sets: (All)
152-
Aliases: wi
153150

154151
Required: False
155152
Position: Named

src/Commands/Pages/ExportPage.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class ExportPage : PnPWebCmdlet
2929
[Parameter(Mandatory = false)]
3030
public ExtractConfigurationPipeBind Configuration;
3131

32+
[Parameter(Mandatory = false)]
33+
public SwitchParameter OutputInstance;
34+
3235
protected override void ProcessRecord()
3336
{
3437
_ = Identity.GetPage(Connection) ?? throw new Exception($"Page '{Identity?.Name}' does not exist");
@@ -95,9 +98,15 @@ private void ExtractTemplate(string dirName, string fileName, ExtractConfigurati
9598
}
9699
else
97100
{
98-
WriteObject(outputTemplate.ToXML());
101+
if (OutputInstance)
102+
{
103+
WriteObject(outputTemplate);
104+
}
105+
else
106+
{
107+
WriteObject(outputTemplate.ToXML());
108+
}
99109
}
100110
}
101111
}
102-
103112
}

0 commit comments

Comments
 (0)