My problem is enabling custom script with DenyAddAndCustomizePages.
A two-line script can describe my problem.
Background: I was using Set-SPOSite to enable it like this:
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False
This worked fine for sites with URLs of the form
https://xxxxx.sharepoint.com/sites/MySite, i.e. top-level sites in the collection.
When I used it on a subsite of MySite, it gave me an error:
(The URL was "https://xxxxx.sharepoint.com/sites/MySite/Subsite1")
The error was:
Set-SPOSite: The managed path sites/Mysite is not a managed path in this tenant.
(It was not seeing past Mysite in the URL).
I found an explanation that appeared to make sense, that Get/Set-SPOSite cmdlets only work at the top-level of the site collection. And suggested to use PnP PowerShell.
So I tried this script:
Connect-PnPOnline -Url $AdminCenterURL -Interactive
Set-PnPTenantSite -Identity $SiteURL -DenyAddAndCustomizePages:$False
It works fine on top-level sites, but on subsites I get the same error:
The managed path sites/MySite is not a managed path in this tenant.
Is there any way of scripting with PnP PowerShell to enable custom scripts on subsites?
(Pls excuse any formatting errors. First post here).
Thanks!
