Skip to content

Commit 46ccefe

Browse files
authored
Merge pull request #2990 from siddharth-vaghasia/dev
added new command Export-PnPPowerApp
2 parents 3f5df14 + 85be173 commit 46ccefe

File tree

8 files changed

+617
-0
lines changed

8 files changed

+617
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
schema: 2.0.0
4+
applicable: SharePoint Online
5+
online version: https://pnp.github.io/powershell/cmdlets/Export-PnPPowerApp.html
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
title: Export-PnPPowerApp
8+
---
9+
10+
# Export-PnPPowerApp
11+
12+
## SYNOPSIS
13+
14+
**Required Permissions**
15+
16+
* Azure: management.azure.com
17+
18+
Exports a Microsoft Power App
19+
20+
## SYNTAX
21+
22+
```
23+
Export-PnPPowerApp -Environment <PowerPlatformEnvironmentPipeBind> -Identity <PowerAppPipeBind>
24+
[-PackageDisplayName <String>] [-PackageDescription <String>] [-PackageCreatedBy <String>]
25+
[-PackageSourceEnvironment <String>] [-OutPath <String>] [-Force] [-Connection <PnPConnection>]
26+
[<CommonParameters>]
27+
```
28+
29+
## DESCRIPTION
30+
This cmdlet exports a Microsoft Power App as zip package.
31+
32+
Many times exporting a Microsoft Power App will not be possible due to various reasons such as connections having gone stale, SharePoint sites referenced no longer existing or other configuration errors in the App. To display these errors when trying to export a App, provide the -Verbose flag with your export request. If not provided, these errors will silently be ignored.
33+
34+
## EXAMPLES
35+
36+
### Example 1
37+
```powershell
38+
$environment = Get-PnPPowerPlatformEnvironment -IsDefault $true
39+
Export-PnPPowerApp -Environment $environment -Identity fba63225-baf9-4d76-86a1-1b42c917a182 -OutPath "C:\Users\user1\Downloads\test_20230408152624.zip"
40+
```
41+
42+
This will export the specified Microsoft Power App from the default Power Platform environment as an output to the path specified in the command as -OutPath
43+
44+
### Example 2
45+
```powershell
46+
$environment = Get-PnPPowerPlatformEnvironment -IsDefault $true
47+
Export-PnPPowerApp -Environment $environment -Identity fba63225-baf9-4d76-86a1-1b42c917a182 -OutPath "C:\Users\user1\Downloads\test_20230408152624.zip" -PackageDisplayName "MyAppDisplayName" -PackageDescription "Package exported using PnP Powershell" -PackageCreatedBy "Siddharth Vaghasia" -PackageSourceEnvironment "UAT Environment"
48+
```
49+
This will export the specified Microsoft Power App from the default Power Platform environment with metadata specified
50+
51+
### Example 3
52+
```powershell
53+
Get-PnPPowerPlatformEnvironment | foreach { Get-PnPPowerApp -Environment $_.Name } | foreach { Export-PnPPowerApp -Environment $_.Properties.EnvironmentDetails.Name -Identity $_ -OutPath "C:\Users\user1\Downloads\$($_.Name).zip" }
54+
```
55+
56+
This will export all the Microsoft Power Apps available within the tenant from all users from all the available Power Platform environments as a ZIP package for each of them to a local folder C:\Users\user1\Downloads
57+
58+
## PARAMETERS
59+
60+
### -Connection
61+
Optional connection to be used by the cmdlet.
62+
Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
63+
64+
```yaml
65+
Type: PnPConnection
66+
Parameter Sets: (All)
67+
Aliases:
68+
69+
Required: False
70+
Position: Named
71+
Default value: None
72+
Accept pipeline input: False
73+
Accept wildcard characters: False
74+
```
75+
76+
### -Environment
77+
The environment which contains the App.
78+
79+
```yaml
80+
Type: PowerPlatformEnvironmentPipeBind
81+
Parameter Sets: (All)
82+
Aliases:
83+
84+
Required: True
85+
Position: Named
86+
Default value: None
87+
Accept pipeline input: False
88+
Accept wildcard characters: False
89+
```
90+
91+
### -Identity
92+
The value of the Name property of a Microsoft Power App that you wish to export
93+
94+
```yaml
95+
Type: PowerAppPipeBind
96+
Parameter Sets: (All)
97+
Aliases:
98+
99+
Required: True
100+
Position: Named
101+
Default value: None
102+
Accept pipeline input: False
103+
Accept wildcard characters: False
104+
```
105+
106+
### -Force
107+
If specified and the file exported already exists it will be overwritten without confirmation.
108+
109+
```yaml
110+
Type: SwitchParameter
111+
Parameter Sets: (All)
112+
Aliases:
113+
114+
Required: False
115+
Position: Named
116+
Default value: None
117+
Accept pipeline input: False
118+
Accept wildcard characters: False
119+
```
120+
121+
### -OutPath
122+
Optional file name of the file to export to. If not provided, it will store the ZIP package to the current location from where the cmdlet is being run.
123+
124+
```yaml
125+
Type: String
126+
Parameter Sets: (All)
127+
Aliases:
128+
129+
Required: False
130+
Position: Named
131+
Default value: None
132+
Accept pipeline input: False
133+
Accept wildcard characters: False
134+
```
135+
136+
### -PackageCreatedBy
137+
The name of the person to be used as the creator of the exported package
138+
139+
```yaml
140+
Type: String
141+
Parameter Sets: (All)
142+
Aliases:
143+
144+
Required: False
145+
Position: Named
146+
Default value: None
147+
Accept pipeline input: False
148+
Accept wildcard characters: False
149+
```
150+
151+
### -PackageDescription
152+
The description to use in the exported package
153+
154+
```yaml
155+
Type: String
156+
Parameter Sets: (All)
157+
Aliases:
158+
159+
Required: False
160+
Position: Named
161+
Default value: None
162+
Accept pipeline input: False
163+
Accept wildcard characters: False
164+
```
165+
166+
### -PackageDisplayName
167+
The display name to use in the exported package
168+
169+
```yaml
170+
Type: String
171+
Parameter Sets: (All)
172+
Aliases:
173+
174+
Required: False
175+
Position: Named
176+
Default value: None
177+
Accept pipeline input: False
178+
Accept wildcard characters: False
179+
```
180+
181+
### -PackageSourceEnvironment
182+
The name of the source environment from which the exported package was taken
183+
184+
```yaml
185+
Type: String
186+
Parameter Sets: (All)
187+
Aliases:
188+
189+
Required: False
190+
Position: Named
191+
Default value: None
192+
Accept pipeline input: False
193+
Accept wildcard characters: False
194+
```
195+
196+
## RELATED LINKS
197+
198+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace PnP.PowerShell.Commands.Model.PowerPlatform.PowerApp.Enums
2+
{
3+
/// <summary>
4+
/// Contains the possible states of a App export request
5+
/// </summary>
6+
public enum PowerAppExportStatus
7+
{
8+
/// <summary>
9+
/// PowerApp export failed
10+
/// </summary>
11+
Failed,
12+
13+
/// <summary>
14+
/// PowerApp exported successfully
15+
/// </summary>
16+
Succeeded,
17+
18+
/// <summary>
19+
/// Export in progress
20+
/// </summary>
21+
Running
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace PnP.PowerShell.Commands.Model.PowerPlatform.PowerApp
4+
{
5+
/// <summary>
6+
/// Contains the error details when requesting an export of a Flow package
7+
/// </summary>
8+
public class PowerAppExportPackageError
9+
{
10+
/// <summary>
11+
/// Error code
12+
/// </summary>
13+
[JsonPropertyName("code")]
14+
public string Code { get; set; }
15+
16+
/// <summary>
17+
/// Description of the error
18+
/// </summary>
19+
[JsonPropertyName("message")]
20+
public string Message { get; set; }
21+
}
22+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace PnP.PowerShell.Commands.Model.PowerPlatform.PowerApp
5+
{
6+
/// <summary>
7+
/// Contains details on a specific resource in a Flow export request
8+
/// </summary>
9+
public class PowerAppExportPackageResource
10+
{
11+
/// <summary>
12+
/// Full identifier path of the resource
13+
/// </summary>
14+
[JsonPropertyName("id")]
15+
public string Id { get; set; }
16+
17+
/// <summary>
18+
/// Identifier of the resource
19+
/// </summary>
20+
[JsonPropertyName("name")]
21+
public string Name { get; set; }
22+
23+
/// <summary>
24+
/// Type of resource
25+
/// </summary>
26+
[JsonPropertyName("type")]
27+
public string Type { get; set; }
28+
29+
/// <summary>
30+
/// Indicator if the resource should be updated or considered a new resource by default on import
31+
/// </summary>
32+
[JsonPropertyName("creationType")]
33+
public string CreationType { get; set; }
34+
35+
/// <summary>
36+
/// Additional details on the resource
37+
/// </summary>
38+
[JsonPropertyName("details")]
39+
public Dictionary<string, string> Details { get; set; }
40+
41+
/// <summary>
42+
/// Indicator who can configure the resource
43+
/// </summary>
44+
[JsonPropertyName("configurableBy")]
45+
public string ConfigurableBy { get; set; }
46+
47+
/// <summary>
48+
/// Indicator where this resource is located in a hierarchical structure
49+
/// </summary>
50+
[JsonPropertyName("hierarchy")]
51+
public string Hierarchy { get; set; }
52+
53+
/// <summary>
54+
/// Indicator if there are dependencies on other resources
55+
/// </summary>
56+
[JsonPropertyName("dependsOn")]
57+
public object[] DependsOn { get; set; }
58+
59+
/// <summary>
60+
/// Suggested approach on import
61+
/// </summary>
62+
[JsonPropertyName("suggestedCreationType")]
63+
public string SuggestedCreationType { get; set; }
64+
}
65+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
4+
5+
namespace PnP.PowerShell.Commands.Model.PowerPlatform.PowerApp
6+
{
7+
/// <summary>
8+
/// Contains the results of a request to export a Flow package
9+
/// </summary>
10+
public class PowerAppPackageWrapper
11+
{
12+
/// <summary>
13+
/// Raw state indicating if the Flow export request was successful
14+
/// </summary>
15+
[JsonPropertyName("status")]
16+
public string StatusRaw { get; set; }
17+
18+
/// <summary>
19+
/// The status of the export request as an enum
20+
/// </summary>
21+
[JsonIgnore]
22+
public Enums.PowerAppExportStatus? Status
23+
{
24+
get { return !string.IsNullOrWhiteSpace(StatusRaw) && Enum.TryParse<Enums.PowerAppExportStatus>(StatusRaw, true, out var result) ? result : (Enums.PowerAppExportStatus?)null; }
25+
set { StatusRaw = value.ToString(); }
26+
}
27+
28+
/// <summary>
29+
/// Contains the resource identifiers
30+
/// </summary>
31+
[JsonPropertyName("baseResourceIds")]
32+
public string[] BaseResourceIds { get; set; }
33+
34+
/// <summary>
35+
/// List with resources contained in the export
36+
/// </summary>
37+
[JsonPropertyName("resources")]
38+
public Dictionary<string, PowerAppExportPackageResource> Resources { get; set; }
39+
40+
/// <summary>
41+
/// Array with errors generated when trying to export the resource
42+
/// </summary>
43+
[JsonPropertyName("errors")]
44+
public PowerAppExportPackageError[] Errors{ get; set; }
45+
}
46+
}

0 commit comments

Comments
 (0)