question

HarikrishnanP-2692 avatar image
0 Votes"
HarikrishnanP-2692 asked HarikrishnanP edited

Usage of Add-PnPContentTypesFromContentTypeHub

Hi,

Has anybody tried using the new command Add-PnPContentTypesFromContentTypeHub to sync content types from the hub to the site collection? I tried to use this command as per the documentation. But I'm getting an error as below.

Add-PnPContentTypesFromContentTypeHub : The type of data at position 249 is different than the one expected.
At line:1 char:1
+ Add-PnPContentTypesFromContentTypeHub -ContentTypes $list -Connection ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPContentTypesFromContentTypeHub], InvalidOperationException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.ContentTypes.AddContentTypesFromContentTypeHub

office-sharepoint-onlinewindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HarikrishnanP avatar image
0 Votes"
HarikrishnanP answered HarikrishnanP edited

This the code I'm currently using

$ctHubUrl = Get-PnPContentTypePublishingHubUrl
Connect-PnPOnline -Url $ctHubUrl
$CTIds = Get-PnPContentType
Write-Output 'Count:' $CTIds.Count
$list = New-Object Collections.Generic.List[string]
foreach($id in $CTIds)
{
$list.Add($id.Id.StringValue)
}
Add-PnPContentTypesFromContentTypeHub -ContentTypes $list -Connection $site
Start-Sleep -s 60
$SiteContnetTypes= Get-PnPContentType -InSiteHierarchy -Connection $site
Write-Output 'Count:' $CTIds.Count

After running this code I got the error 'The type of data at position 280 is different than the one expected.' But I confirmed that the count of content types in the hub and new site are the same using the above code.

To verify the same using the UI I checked the Content-type gallery (/_layouts/15/SiteAdmin.aspx#/contentTypes) of the new site, I can see that all content types are added but if check the classic UI (/_layouts/15/mngctype.aspx) custom content types are not appearing there.

Is this an expected behavior?

What I want to do is, I want to add a content type to the list using a site design script. Previously we were relying on 1-hour delay to sync the content types to the new site. Now we removed it and tried the above code, but the problem is site design is not adding the content type to the list. I also tried the command Add-PnPContentTypeToList, which is also not working.

This will work if we wait for 1 hour and the classic UI is populated with all the content types. Any idea on this issue?

Note: I also noticed that even if we don't run the above code, immediately after creating the site Content type gallery (/_layouts/15/SiteAdmin.aspx#/contentTypes) will have all the custom content types populated by default. Not sure if this be the case once MS turn off content type sync in feb.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HarikrishnanP-2692 avatar image
0 Votes"
HarikrishnanP-2692 answered HarikrishnanP-2692 commented

I have raised a ticket with Microsoft. They said PnP is not an MS product, so they can't do the support for the same. It's interesting that MS only suggested using this command. Considering that its only 2 weeks left to stop the automatic synchronization, it's really frustrating.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Surely if the underlying CSOM is causing the issue, this is indeed a problem Microsoft will need to address?

0 Votes 0 ·

Yes, but they simply responded in this way. Based on the confirmation, they will not be immediately stopping automatic content type synchronization this month. It might be due to this error even though they are not agreeing on it.

0 Votes 0 ·
YiLu-MSFT avatar image
0 Votes"
YiLu-MSFT answered CallumCrowley commented

Hi @HarikrishnanP-2692
Since I could not search any documents to explain this issue, I suggest you could open a service request in Microsoft 365 admin center for better help.
131082-image.png



If an 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.



image.png (24.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This isn't an individual tenant problem, it's affecting multiple tenants. Surely this has to be raised through a different channel?

The issue is with Microsoft.SharePointOnline.CSOM as described by those attempting to use PnP.PowerShell (which relies on this library):

https://github.com/pnp/powershell/issues/1080

0 Votes 0 ·
HarikrishnanP-2692 avatar image
0 Votes"
HarikrishnanP-2692 answered CallumCrowley commented

I even tried in Azure runbook, I was getting the same error. We are using some content types based logic in the script,so according to Microsoft auto-syncing of content type will stop this month. So this is very critical .

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Agreed, this is very important to our project and we've implemented the cmdlet under the assumption that it is production ready.

1 Vote 1 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered CallumCrowley commented

Hello @HarikrishnanP-2692

I may recommend you to give a read to the sintex changes in SharePoint published last month. The "write error" seems like the input is not as expected.

Check: https://techcommunity.microsoft.com/t5/sharepoint-syntex/syntex-product-updates-august-2021/ba-p/2606438

Hope this helps you,
Best regards

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm experiencing the exact same issue. I have implemented the PowerShell exactly as described and this was working up until the end of last week. I tried running the cmdlet this morning and it is throwing this error. It's not clear if it is adding the content types to the site, despite throwing the error.

1 Vote 1 ·

Its not saying about any syntax changes related to the command. I have tried the same code published in PnP Github,but that also not working

$list = New-Object Collections.Generic.List[string]
$list.Add('0x0101')
$list.Add('0x01')
Add-PnPContentTypesFromContentTypeHub -ContentTypes $list

0 Votes 0 ·

It's not an issue with our implementation of the cmdlet, I think it's a problem with the underlying CSOM unfortunately, as described in the GitHub issue:

https://github.com/pnp/powershell/issues/1080

0 Votes 0 ·