Set-PnPTenantSite throws error: "The type of data at position nnnn is different than the one expected"
Since 16th January 2024, running Set-PnPTenantSite with the DisableSharingForNonOwners switch results in an error "The type of data at position 3331 is different than the one expected". (The position number varies.) Multiple tenancies are affected.
Expected behavior
Cmdlet runs without error.
Actual behavior
Cmdlet returns error message. Full error trace from Azure Function invocation below. Issue replicated directly on Windows as well as in Azure Functions.
EXCEPTION: The type of data at position 3379 is different than the one expected.
Exception :
Type : System.Management.Automation.PSInvalidOperationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The type of data at position 3379 is different than the one expected.
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvalidOperation
TargetSite :
Name : ProcessRecord
DeclaringType : PnP.PowerShell.Commands.Base.PnPConnectedCmdlet
MemberType : Method
Module : PnP.PowerShell.dll
Message : The type of data at position 3379 is different than the one expected.
Source : PnP.PowerShell
HResult : -2146233079
StackTrace :
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 101
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 113
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : InvalidOperation: (:) [Set-PnPTenantSite], PSInvalidOperationException
FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.SetTenantSite
InvocationInfo :
MyCommand : Set-PnPTenantSite
ScriptLineNumber : 83
OffsetInLine : 5
HistoryId : 1
ScriptName : C:\home\site\wwwroot\[Redacted]\run.ps1
Line : Set-PnPTenantSite -Identity $projectSiteUrl -DisableSharingForNonOwners -SharingCapability Disabled -StorageQuota 25600 -Connection $connectionAdminSite
PositionMessage : At C:\home\site\wwwroot\[Redacted]\run.ps1:83 char:5
+ Set-PnPTenantSite -Identity $projectSiteUrl -DisableSharingForNon …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\home\site\wwwroot\[Redacted]
PSCommandPath : C:\home\site\wwwroot\[Redacted]\run.ps1
InvocationName : Set-PnPTenantSite
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\[Redacted]\run.ps1: line 83
Steps to reproduce behavior
Connect-PnPOnline https://tenantname-admin.sharepoint.com -Interactive
$site = "https://tenantname.sharepoint.com/sites/anysite"
Set-PnPTenantSite -Identity $site -DisableSharingForNonOwners
What is the version of the Cmdlet module you are running?
2.2.0 2.3.0
Which operating system/environment are you running PnP PowerShell on?
- [X] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [X] Azure Functions
- [ ] Other : please specify
it seems issue with the underlying CSOM API, because Disable-PnPSharingForNonOwnersOfSite -Identity https://tenant.sharepoint.com/sites/oursite is also failing..
hi @siddharth-vaghasia , @jrjlee - looks like Microsoft changed something in the CSOM implementation.
Please raise a ticket with Microsoft support team as well as open it here for wider visibility, https://github.com/SharePoint/sp-dev-docs/issues.
The basic steps to repro which you should mention to them is as below:
Office365Tenant office365Tenant = new Office365Tenant(context);
context.Load(office365Tenant);
office365Tenant.DisableSharingForNonOwnersOfSite(siteUrl);
context.ExecuteQueryRetry();
Am going to close the issue here since we can't do anything about it, only Microsoft can help here.
Can confirm that it’s working fine again on PnP PowerShell 2.3.44-nightly.