Skip to content

Commit bc264bc

Browse files
author
Antti K. Koskela
committed
Adds an example on how to use the Get-PnPContext to disable customizing pages
1 parent 959e629 commit bc264bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sharepoint/sharepoint-ps/sharepoint-pnp/Get-PnPContext.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ $ctx = Get-PnPContext
2020

2121
This will put the current context in the $ctx variable.
2222

23+
### ------------------EXAMPLE 2------------------
24+
```powershell
25+
$ctx = Get-PnPContext
26+
$site = Get-PnPTenantSite -Detailed -Url 'https://contoso.sharepoint.com/'
27+
28+
$site.DenyAddAndCustomizePages = [Microsoft.Online.SharePoint.TenantAdministration.DenyAddAndCustomizePagesStatus]::Disabled
29+
30+
$site.Update()
31+
$ctx.ExecuteQuery()
32+
```
33+
34+
This will first get the context, then get a SPSite object, enable Custom Scripts on it, and finally commit changes by calling ExecuteQuery
35+
2336
## OUTPUTS
2437

2538
### Microsoft.SharePoint.Client.ClientContext

0 commit comments

Comments
 (0)