You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows to apply a site template on a web. The template can be in XML format or a .pnp package. The cmdlet will apply the template to the web you are currently connected to, unless you provide the -Url parameter. You can specify which parts of the template to apply by using the Handlers parameter or just omit it to apply the entire template.
Applies a site template in XML format to the current web. Any resources like files that are referenced in the template will be retrieved from the folder as specified with the ResourceFolder parameter.
66
76
67
-
### EXAMPLE 3
77
+
### EXAMPLE 4
68
78
```powershell
69
79
Invoke-PnPSiteTemplate -Path template.xml -Parameters @{"ListTitle"="Projects";"parameter2"="a second value"}
70
80
```
@@ -73,28 +83,28 @@ Applies a site template in XML format to the current web. It will populate the p
73
83
74
84
For instance with the example above, specifying {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.
Applies a site template from an in-memory instance of a SiteTemplate type of the PnP Core Component, reading the supporting files, if any, from the current (.\) path. The syntax can be used together with any other supported parameters.
When set to true, the cmdlet will not block you from applying the template to the SharePoint Online Admin Center site collection, which is not recommended. Use with care!
199
+
200
+
```yaml
201
+
Type: Boolean
202
+
Parameter Sets: (All)
203
+
204
+
Required: False
205
+
Position: Named
206
+
Default value: False
207
+
Accept pipeline input: False
208
+
Accept wildcard characters: False
209
+
```
210
+
187
211
### -Handlers
188
212
Allows you to only process a specific part of the template. Notice that this might fail, as some of the handlers require other artifacts in place if they are not part of what your applying. Visit https://learn.microsoft.com/dotnet/api/officedevpnp.core.framework.provisioning.model.handlers for possible values.
189
213
@@ -355,7 +379,19 @@ Accept pipeline input: False
355
379
Accept wildcard characters: False
356
380
```
357
381
382
+
### -Url
383
+
Optionally allows you to specify the URL of the web to apply the template to. If not specified, the template will be applied to the currently connected web. It takes precedence over the current context and requires a full URL to a web, i.e. https://tenant.sharepoint.com/sites/somesite, not just a site collection relative URL.
thrownewPSInvalidOperationException($"The hostname '{uri}' which you have provided to apply the template to is invalid and does not exist.",e);
95
+
}
96
+
catch(Exceptione)
97
+
{
98
+
thrownewPSInvalidOperationException($"Unable to connect to the SharePoint Online Admin site at '{uri}' to run apply the template to. Error message: {e.Message}",e);
99
+
}
100
+
LogDebug($"Connected to the SharePoint Online site at '{uri}' to apply the template");
101
+
}
102
+
else
103
+
{
104
+
thrownewArgumentException("The Identity parameter, when provided, must be a valid full URL to the site collection to apply the template to.",nameof(Identity));
105
+
}
106
+
}
107
+
else
108
+
{
109
+
// If the Identity/Url parameter has not been specified, we will use the current context to apply the template to
110
+
applyTemplateContext=ClientContext;
111
+
}
112
+
113
+
// Avoid the template being applied to a tenant admin site
// If the current context is a tenant admin site, we cannot apply a site template to it
117
+
thrownewPSInvalidOperationException($"You cannot apply a site template to a tenant admin site. Please connect to a site collection or subsite to apply the template or use the {nameof(Identity)} parameter to specify which sitecollection it should be applied to. If you are sure you want to apply the template to a tenant admin site, please use the -{nameof(Force)} parameter to override this check.");
0 commit comments