Set-PnPTenantSite -SharingCapability issue...

Frankster 26 Reputation points
2022-11-02T19:42:43.633+00:00

Greetings to all!

I have no problems whatsoever setting SPO tenant-level sharing settings on a test site using the Set-SPOSite cmdlet with the '-SharingCapability' parameter. None.

BUT when I try to use the Set-PnPTenantSite cmdlet with the '-SharingCapability' parameter nothing happens. It's been about 30 minutes since I ran the following command, and the tenant sharing is still at the most permissive setting...

Set-PnPTenantSite -Identity https://mysposite.sharepoint.com -SharingCapability Disabled  

Note that I checked my version of the PnP.SharePoint module and it's version 1.11.0.

Am I making a mistake, or is something wrong with this PnP cmdlet?

THANKS!

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,598 questions
0 comments No comments
{count} vote

Accepted answer
  1. Jinwei Li-MSFT 4,721 Reputation points Microsoft Vendor
    2022-11-04T02:50:18.783+00:00

    Hi @Frankster ,

    This is for the tenant level PnP-PowerShell code:

    #Parameters  
    $TenantAdminURL = "https://crescent-admin.sharepoint.com"  
        
    #Connect to Tenant Admin Site  
    Connect-PnPOnline -url $TenantAdminURL -Interactive  
        
    #Disable External Sharing for the tenant  
    Set-PnPTenant -SharingCapability Disabled  
    

    This is for the site level PnP-PowerShell code:

    #Parameters  
    $TenantAdminURL = "https://crescent-admin.sharepoint.com"  
    $SiteURL = "https://crescent.sharepoint.com/sites"  
        
    #Connect to Tenant Admin Site  
    Connect-PnPOnline -url $TenantAdminURL -Interactive  
       
    #Disable External Sharing for a site  
    Set-PnPTenantSite -Url $SiteURL -SharingCapability Disabled  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Jinwei Li-MSFT 4,721 Reputation points Microsoft Vendor
    2022-11-03T07:03:42.43+00:00

    Hi @Frankster ,

    This issue cannot be reproduced from my end. Please try to use this PnP-PowerShell:

    #Parameters  
    $TenantAdminURL = "https://crescent-admin.sharepoint.com"  
    $SiteURL = "https://crescent.sharepoint.com/sites/sitename"  
        
    #Connect to Tenant Admin Site  
    Connect-PnPOnline -url $TenantAdminURL -Interactive  
       
    #Disable External Sharing for a site  
    Set-PnPTenantSite -Url $SiteURL -SharingCapability Disabled  
    

    If PnP-PowerShell still not working, I suggest you could use PowerShell to further restrict sharing settings on individual SharePoint sites.

    #Set Admin Center URL  
    $AdminCenterURL = "https://crescent-admin.sharepoint.com/"  
    $SiteURL="https://crescent.sharepoint.com/sites/sitename"  
       
    #Connect to SharePoint Online  
    Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)  
       
    #Disable external sharing  
    Set-SPOSite $SiteURL -SharingCapability "Disabled"  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    0 comments No comments

  2. Frankster 26 Reputation points
    2022-11-03T14:37:39.037+00:00

    JinweiLi-MSFT,

    Thank you for your prompt response!

    Correct me if I'm wrong, but if you want to set the sharing at the TENANT level, not the SITE level, you would use a URL like...

    https://crescent.sharepoint.com

    ...NOT like this...

    https://crescent.sharepoint.com/sites/sitename

    It looks to me that your line of code...

    Set-PnPTenantSite -Url $SiteURL -SharingCapability Disabled  
    

    ...is attempting to set the sharing for a SITE, not the TENANT.

    Again, please correct me if I'm mistaken.

    THANKS AGAIN!


  3. Frankster 26 Reputation points
    2022-11-04T22:29:18.87+00:00

    JinweiLi-MSFT,

    Got it! I was using Set-PnPTenantSite instead of Set-PnPTenant. Of course.

    THANK YOU!!!

    Take care

    0 comments No comments