Unable to run set-sposite -Disablesharingfornonowners

Brass Contributor

Running the SPO PowerShell

```PowerShell

$AdminSiteURL= "https://contoso-admin.sharepoint.com"
$SiteURL= "https://contoso.sharepoint.com/sites/testclone2"

#Connect to SharePoint Online services
Connect-SPOService -url $AdminSiteURL

#Disable Sharing for Non-Owners
Set-SPOSite -Identity $SiteURL -DisableSharingForNonOwners

```
set-pnpsite -Disablesharingfornonowners
Set-PnPSite: The type of data at position 3330 is different than the one expected.

8 Replies

@reshmeeauckloo Are you trying it using both SPO PowerShell and PnP PowerShell?

 

Error message you shared is for PnP PowerShell. Is it throwing same error using SPO PowerShell as well?

 

Make sure you are using SharePoint Online Management Shell Version 16.0.4613.1211 or later while using SPO PowerShell.

 

Example: 

 

Set-SPOSite -Identity https://contoso.sharepoint.com/sites/mysite -DisableSharingForNonOwners

 

DocumentationSet-SPOSite 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Upgrading SPO PowerShell to the latest resolved the issue. I could reproduce the issue with both PnP PowerShell and SPO PowerShell. I could still reproduce the issue with PnP PowerShell.

@reshmeeauckloo Great, glad it worked using latest version of SPO PowerShell.

 

Maybe something changed in SharePoint backend which is not yet updated in PnP PowerShell command. So I will suggest you to raise a new issue at: PnP PowerShell Issues.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Yeah I did raise it with PnP PowerShell and we agreed it is something with SP CSOM and closed the ticket. I need to try it with the latest nightly build before raising it back again if it is still an issue. Thanks very much for your help on this @ganeshsanap.

@ganeshsanap, thank you for this information, as you provided Documentation link we can see this is a official Microsoft announcement. My question is where I can find this famous SharePoint Online Management Shell Version 16.0.4613.1211 ?? As on Microsoft official download site is unavailable same as on other pwsh repository, I cannot find nothing about this version of SPO management shell. Would you be so kind and share how\from where I can download mentioned above SPO shell. 

 

I will be grateful for help 

@artlavxv 

 

Try uninstalling all previously installed versions of SharePoint Online Management Shell and then download-install latest version from either of below links:

 

  1. SharePoint Online Management Shell - I download latest versions from here every time
  2. PowerShell Gallery - Microsoft.Online.SharePoint.PowerShell 

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

@ganeshsanap 

 

sorry for late reply, before I asked question here I made my own investigation and of course I already installed newest version from links you provided (I also always using this one https://www.microsoft.com/en-in/download/details.aspx?id=35588), but as you probably already notes the available newest version is 16.0.24510.12000 there is no place where I can download SharePoint Online Management Shell Version 16.0.4613.1211. For me installing newest version of SPO management shell didn't fix the issue. I will try as you suggest remove all spo shell and install one more time. I'll let you know, thanks   

I could not reproduce the issue anymore even via PnP PowerShell or SPO PowerShell, I presume MS has fixed it in the backend.