none
Disable and Enable External Sharing through Powershell

    Question

  • Hello All,

    We are using On drive For Business in our organization.Due to security reasons we would like to disable the external Sharing option. But we don't want to do that at Tenant level. We want to disable External Sharing option at individual user level. I found this script that disables external Sharering

    set-sposite https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com  -SharingCapability disable 

    I need a same kind of script to enalble the disabled sites. Could you please help me with the script

    Thanks in Advance

    Ujwala

    Thursday, February 11, 2016 4:55 PM

Answers

  • The same cmdlet allows you to Enable sharing. This example is for sharing via email (MicrosoftID):

    set-sposite https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com  -SharingCapability  ExternalUserSharingOnly

    And this one is for both for MicrosoftID and Guest links:

    set-sposite https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com  -SharingCapability  ExternalUserAndGuestSharing

    • Edited by Vasil L. MichevMVP Thursday, February 11, 2016 9:18 PM formatting
    • Marked as answer by UjwalaIDC Saturday, February 13, 2016 7:34 PM
    Thursday, February 11, 2016 9:10 PM
  • As the error says, you have a more restrictive setting applied on the tenant level. You cannot disable external sharing on the tenant level and enable it on a single user only. Instead, leave it enabled for the tenant, but disable it for all users except the ones you want.

    In other words, check these two cmdlets and enable sharing as necessary:

    Get-SPOTenant | fl SharingCapability
    
    Get-sposite https://michev-my.sharepoint.com/ | Fl SharingCapability

    • Marked as answer by UjwalaIDC Saturday, February 13, 2016 7:33 PM
    Friday, February 12, 2016 2:32 PM

All replies

  • The same cmdlet allows you to Enable sharing. This example is for sharing via email (MicrosoftID):

    set-sposite https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com  -SharingCapability  ExternalUserSharingOnly

    And this one is for both for MicrosoftID and Guest links:

    set-sposite https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com  -SharingCapability  ExternalUserAndGuestSharing

    • Edited by Vasil L. MichevMVP Thursday, February 11, 2016 9:18 PM formatting
    • Marked as answer by UjwalaIDC Saturday, February 13, 2016 7:34 PM
    Thursday, February 11, 2016 9:10 PM
  • Thanks Vasil for your reply. But i am getting the below error while enabling External sharing using above commands 

    set-sposite : You can’t set the sharing capability to the level you specified, because it is a less restrictive setting than either its parent site collection or your

    organization.

    At line:5 char:1

    + set-sposite 

    https://mytenant-my.sharepoint.com/personal/mypersoanalsite_com

    ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [Set-SPOSite], ServerException

        + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.SetSite  

    Please help

    Friday, February 12, 2016 1:09 PM
  • As the error says, you have a more restrictive setting applied on the tenant level. You cannot disable external sharing on the tenant level and enable it on a single user only. Instead, leave it enabled for the tenant, but disable it for all users except the ones you want.

    In other words, check these two cmdlets and enable sharing as necessary:

    Get-SPOTenant | fl SharingCapability
    
    Get-sposite https://michev-my.sharepoint.com/ | Fl SharingCapability

    • Marked as answer by UjwalaIDC Saturday, February 13, 2016 7:33 PM
    Friday, February 12, 2016 2:32 PM
  • Excellent.  Thank you So much for your help. It helped me to resolve my issue. 
    Saturday, February 13, 2016 7:34 PM
  • Hai Vasil

    is the above script will change any settings on Tenant level, i have a permission to enable "Allow external users who accept sharing invitations and sign in as authenticated users" from admin site

    but wen i am running script says error which Ujwala posted above,

    i am running below srcipt for enable above settings

    Connect-SPOService https://sharepoint-admin.sharepoint.com
    $SC=Get-SPOSite https://sharepoint.sharepoint.com/site
    $SC.SharingCapability
    Set-SPOSite -Identity https://sharepoint.sharepoint.com/site -SharingCapability ExternalUserAndGuestSharing

    error

    WARNING: The SharingCapability set for this SPOSite will not take effect until the 'ExternalUserAndGuestSharing' SharingCapability is also enabled on the SPOTenant.
    Set-SPOSite : You can’t set the sharing capability to the level you specified, because it is a less restrictive setting than either its parent site collection or your 
    organization.
    At line:4 char:1
    + Set-SPOSite -Identity https://sharepoint.sharepoint.com/site
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Set-SPOSite], ServerException
        + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.SetSite

    Can kindly help me,

     


    kmk

    Monday, January 23, 2017 1:31 PM
  • hai 

    can u please share me you comments regrading the above same.

    how its solved?

    did it change any thing changed alredy saved settings on tenant?

    help me

     


    kmk

    Monday, January 23, 2017 1:37 PM