Skip to content

Commit a686058

Browse files
committed
Removed ability to override check for provisioning to tenant admin site
1 parent bb9bb63 commit a686058

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

documentation/Invoke-PnPSiteTemplate.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Invoke-PnPSiteTemplate -Path <String> [-TemplateId <String>] [-ResourceFolder <S
2121
[-ProvisionFieldsToSubWebs] [-ClearNavigation] [-Parameters <Hashtable>] [-Handlers <Handlers>]
2222
[-ExcludeHandlers <Handlers>] [-ExtensibilityHandlers <ExtensibilityHandler[]>]
2323
[-TemplateProviderExtensions <ITemplateProviderExtension[]>]
24-
[-Force <boolean>] [-Url <String>]
24+
[-Url <String>]
2525
[-Connection <PnPConnection>]
2626
```
2727

@@ -32,7 +32,7 @@ Invoke-PnPSiteTemplate -InputInstance <SiteTemplate> [-TemplateId <String>] [-Re
3232
[-ProvisionFieldsToSubWebs] [-ClearNavigation] [-Parameters <Hashtable>] [-Handlers <Handlers>]
3333
[-ExcludeHandlers <Handlers>] [-ExtensibilityHandlers <ExtensibilityHandler[]>]
3434
[-TemplateProviderExtensions <ITemplateProviderExtension[]>]
35-
[-Force <boolean>] [-Url <String>]
35+
[-Url <String>]
3636
[-Connection <PnPConnection>]
3737
```
3838

@@ -43,7 +43,7 @@ Invoke-PnPSiteTemplate -Stream <Stream> [-TemplateId <String>] [-ResourceFolder
4343
[-ProvisionFieldsToSubWebs] [-ClearNavigation] [-Parameters <Hashtable>] [-Handlers <Handlers>]
4444
[-ExcludeHandlers <Handlers>] [-ExtensibilityHandlers <ExtensibilityHandler[]>]
4545
[-TemplateProviderExtensions <ITemplateProviderExtension[]>]
46-
[-Force <boolean>] [-Url <String>]
46+
[-Url <String>]
4747
[-Connection <PnPConnection>]
4848
```
4949

@@ -194,20 +194,6 @@ Accept pipeline input: False
194194
Accept wildcard characters: False
195195
```
196196
197-
### -Force
198-
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-
211197
### -Handlers
212198
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.
213199

src/Commands/Provisioning/Site/InvokeSiteTemplate.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ public class InvokeSiteTemplate : PnPSharePointCmdlet
7171
[Alias("Url")]
7272
public string Identity { get; set; }
7373

74-
[Parameter(Mandatory = false)]
75-
public bool? Force { get; set; }
76-
7774
protected override void ExecuteCmdlet()
7875
{
7976
ClientContext applyTemplateContext = null;
@@ -110,11 +107,12 @@ protected override void ExecuteCmdlet()
110107
applyTemplateContext = ClientContext;
111108
}
112109

110+
113111
// Avoid the template being applied to a tenant admin site
114-
if (Force.GetValueOrDefault(false) && PnPConnection.IsTenantAdminSite(applyTemplateContext))
112+
if (PnPConnection.IsTenantAdminSite(applyTemplateContext))
115113
{
116114
// If the current context is a tenant admin site, we cannot apply a site template to it
117-
throw new PSInvalidOperationException($"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.");
115+
throw new PSInvalidOperationException($"You cannot apply a site template to a tenant admin site. Please connect to a site collection or use the {nameof(Identity)} parameter to specify which sitecollection it should be applied to.");
118116
}
119117

120118
applyTemplateContext.Web.EnsureProperty(w => w.Url);

0 commit comments

Comments
 (0)