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

SharePoint Online: Como localizar los usuarios externos en un tenant (II)!

Siguiendo con la serie de artículos sobre como localizar los usuarios externos en un tenant de SharePoint Online, en esta ocasión os comparto la opción de hacerlo a través de PowerShell como mecanismo más preciso de obtener dicha información haciendo uso del comando Get-SPOExternalUser en un Script PowerShell que podéis descargaros desde el siguiente enlace: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

La correspondiente salida por pantalla es la siguiente:

image