Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomScriptSafeDomains.Create returns "Cannot convert the "Microsoft.SharePoint.Client.ScriptSafeDomainEntityData" #1694

Closed
1 of 6 tasks
djsladi opened this issue Mar 15, 2022 · 6 comments · Fixed by #2363
Labels
more info needed Further information is requested by user

Comments

@djsladi
Copy link

djsladi commented Mar 15, 2022

Reporting an Issue or Missing Feature

Error when trying to set HTML field security using latest PnP & SharePoint Online Management Shell

Expected behavior

Domain should be added to HTML field list

Actual behavior

image

Cannot convert argument "parameters", with value: "Microsoft.SharePoint.Client.ScriptSafeDomainEntityData", for "Create
" to type "Microsoft.SharePoint.Client.ScriptSafeDomainEntityData": "Cannot convert the "Microsoft.SharePoint.Client.Sc
riptSafeDomainEntityData" value of type "Microsoft.SharePoint.Client.ScriptSafeDomainEntityData" to type "Microsoft.Sha
rePoint.Client.ScriptSafeDomainEntityData"."

Steps to reproduce behavior

$Domain = [Microsoft.SharePoint.Client.ScriptSafeDomainEntityData]::new()
$Domain.DomainName = "test.com"
Connect-PnPOnline -Url $siteColl -Interactive
$site = Get-PnPSite -Includes CustomScriptSafeDomains
$site.CustomScriptSafeDomains.Create($Domain)

What is the version of the Cmdlet module you are running?

1.9.0

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@djsladi djsladi added the bug Something isn't working label Mar 15, 2022
@gautamdsheth
Copy link
Collaborator

Seems to work fine at my end, can you please try with the latest 1.10 version as well and check ?

You also need to execute Invoke-PnPQuery after $site.CustomScriptSafeDomains.Create($Domain) to add this to the field security list.

@gautamdsheth gautamdsheth added more info needed Further information is requested by user and removed bug Something isn't working labels Jun 12, 2022
@djsladi
Copy link
Author

djsladi commented Jun 15, 2022

image

No, it's not working... :-(

Seems to work fine at my end, can you please try with the latest 1.10 version as well and check ?

You also need to execute Invoke-PnPQuery after $site.CustomScriptSafeDomains.Create($Domain) to add this to the field security list.

@katjones23
Copy link

I'm receiving the same error today with the same syntax @djsladi has, though it worked fine yesterday.

@katjones23
Copy link

I have a work around that appears to be working consistently at this time:

$Site = Get-PnPSite -Includes CustomScriptSafeDomains 

$object = [PSCustomObject]@{
       DomainName = <#Domain name goes here#>
}

$Site.CustomScriptSafeDomains.Create($object)

@djsladi
Copy link
Author

djsladi commented Sep 13, 2022

I have a work around that appears to be working consistently at this time:

$Site = Get-PnPSite -Includes CustomScriptSafeDomains 

$object = [PSCustomObject]@{
       DomainName = <#Domain name goes here#>
}

$Site.CustomScriptSafeDomains.Create($object)

This one did the trick, thank you very much! :-)

@gautamdsheth
Copy link
Collaborator

hi @djsladi , @katjones23 - we have added a new ScriptSafeDomainName parameter to set-pnpsite cmdlet.
It will be available from tomorrow's nightly builds and the next major version
Am closing this issue hence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Further information is requested by user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants