Office 365: How to get the sharing option applied to each site collection in SPO (II)!

Another approach to get the sharing option applied to each site collection in a SharePoint Online (SPO) tenant is by using PowerShell. You can download the script that allows to get such information from here:https://gallery.technet.microsoft.com/How-to-get-sharing-status-d28b8523

function Get-SPOSharingStatus_SPO_Site_Collections
{
    param ($sSPOSharingCapability)
    try
    {   
        Write-Host "Getting al SPO Site Collections with Sharing Status equals to $sSPOSharingCapability" -ForegroundColor Green
        switch ($sSPOSharingCapability) 
        { 
        "Disabled" {
                Get-SPOSite |Where-Object {$_.SharingCapability -eq $sSPOSharingCapability}|select Url,SharingCapability
            }
        "Enabled"{
                Get-SPOSite |Where-Object {$_.SharingCapability -ne "Disabled"}|select Url,SharingCapability
            }
        "ExternalUserSharingOnly"{            
            Get-SPOSite |Where-Object {$_.SharingCapability -eq $sSPOSharingCapability}|select Url,SharingCapability
            }
        "ExternalUserAndGuestSharing"{
            Get-SPOSite |Where-Object {$_.SharingCapability -eq $sSPOSharingCapability}|select Url,SharingCapability
            }
        default{
            Write-Host "Requested operation is not valid" -ForegroundColor Red
            }           
        }    

    }
    catch [System.Exception]
    {
        Write-Host -Foregroundcolor Red $_.Exception.ToString()   
    }    
}

#Connection to Office 365
$sUserName="<O365User>@<O365Domain>.onmicrosoft.com"
$sSPOAdminCenterUrl="https://<O365Domain>-admin.sharepoint.com/"
$sPassword="<O365Password>"
$sSecurePassword=ConvertTo-SecureString "" -asplaintext -force
$msolcred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $sUserName, $sSecurePassword
Connect-SPOService -Url $sSPOAdminCenterUrl -Credential $msolcred

#Sharing Capability Disabled
$sSPOSharingCapability="Disabled"        
#Get-SPOSharingStatus_SPO_Site_Collections -sSPOSharingCapability $sSPOSharingCapability

#Sharing Capability Enabled -> Two options: Enabled with external users & Enabled with external users + Guest links
$sSPOSharingCapability="Enabled"        
#Get-SPOSharingStatus_SPO_Site_Collections -sSPOSharingCapability $sSPOSharingCapability

#Sharing Capability Enabled -> Enabled with external users
$sSPOSharingCapability="ExternalUserSharingOnly"        
#Get-SPOSharingStatus_SPO_Site_Collections -sSPOSharingCapability $sSPOSharingCapability

#Sharing Capability Enabled -> Enabled with external users and Guest links
$sSPOSharingCapability="ExternalUserAndGuestSharing"        
#Get-SPOSharingStatus_SPO_Site_Collections -sSPOSharingCapability $sSPOSharingCapability
Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s