SharePoint Online: How to find all the external users in a tenant (II)!

In this article I showed you how to get external users in a SharePoint Online tenant using the SharePoint Online administration. A better approach to get all the external users in a SharePoint Online tenant is by using PowerShell and the Get-SPOExternalUser cmdlet:How to get all the external users in a SharePoint Online Tenant!

############################################################################################################################################

# Script that allows to get all the external users in a SharePoint Online Tenant.

# Required Parameters:

#  -> $sUserName: User Name to connect to the SharePoint Admin Center.

#  -> $sMessage: Message to show in the user credentials prompt.

#  -> $sSPOAdminCenterUrl: SharePoint Admin Center Url

############################################################################################################################################

 

$host.Runspace.ThreadOptions = "ReuseThread"

 

#Definition of the function that gets all the external users in a SharePoint Online Tenant.

function Get-SPOExternalUsers

{

    param ($sUserName,$sMessage,$sSPOAdminCenterUrl)

    try

    {    

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        Write-Host "Getting all the external users in a SharePoint Online Tenant" -foregroundcolor Green

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        $msolcred = Get-Credential -UserName $sUserName -Message $sMessage

        Connect-SPOService -Url $sSPOAdminCenterUrl -Credential $msolcred 

        Get-SPOExternalUser -Position 0 -PageSize 30 | Select DisplayName,EMail | Format-Table

 

    }

    catch [System.Exception]

    {

        write-host -f red $_.Exception.ToString()   

    }    

}

 

#Connection to Office 365

$sUserName="<YourOffice365Account>"

$sMessage="Introduce your SPO Credentials"

$sSPOAdminCenterUrl="https://<YourDomain>-admin.sharepoint.com/"

 

Get-SPOExternalUsers -sUserName $sUserName -sMessage $sMessage -sSPOAdminCenterUrl $sSPOAdminCenterUrl

And this is the output you will get once you run the script:

image

Un pensamiento en “SharePoint Online: How to find all the external users in a tenant (II)!

  1. Pingback: SharePoint 2013: Resumen de posts (LXIV)! | Pasión por la tecnología...

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