Solved this with the following code
$removed= $Site.CustomScriptSafeDomains.GetByDomainName("test.com")
$removed.deleteobject()
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
As the title states, I am working on a script and need to have the ability to remove links from the allowed domains section of HTML Field Security of Sharepoint Online.....
as an example the below code successfully adds links.
$SiteURL = "https://crescentintranet.sharepoint.com/sites/marketing"
Connect-PnPOnline -Url $SiteURL -UseWebLogin
$Site = Get-PnPSite -Includes CustomScriptSafeDomains
$Domain = [Microsoft.SharePoint.Client.ScriptSafeDomainEntityData]::new()
$Domain.DomainName = "products.crescent.com"
$Site.CustomScriptSafeDomains.Create($Domain)
Invoke-PnPQuery
Solved this with the following code
$removed= $Site.CustomScriptSafeDomains.GetByDomainName("test.com")
$removed.deleteobject()
Hi @Spencer Cooper ,
You could try to remove links manully:
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hello RowdeyCooper,
Your code seems completely fine to me.
But before code execution Add Trusted Domain To HTML Field security List using the below step.
Online Site Collection >> Site Settings >> Select "HTML Field Security" from Site Collection Administration.
Choose Allow Contributors to insert iframe" Option
Add your preference and Click Ok.
and consider Switching On the Custom Script before the process.
Hope this answers all your queries, if not please do repost back.
If an Answer is helpful, please click "Accept Answer" and upvote it : )