Skip to main content

Power shell Script to get External Users on Office 365

Hello Everyone, 

Below is the Powershell script to get all external users from office 365 tenant.

#---------------------------------------------------------------------------------------------------------------------------
$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="Enter SPO Credentials"
$sSPOAdminCenterUrl="https://<YourDomain>-admin.sharepoint.com/"

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

Comments

Popular posts from this blog

SharePoint Framework extensions to Call Azure Function

In this article, we will talk about prerequisites, how to call Azure Function from SPFX extension, How to Create HHTP function, connect Visual Styuid editor to Azure and publish them, and Set Up CORS on the Azure Function, Create SharePoint Framework Extension, Azure Function, etc. Prerequisites :  Azure Subscriptions   VS code  Spfx Development Env  -   Step by steps details: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment  Follow the below steps to create Azure Functions in the Azure portal.  Steps by steps guide:  https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient-enterpriseapi    Reference :  https://docs.microsoft.com/en-us/answers/questions/430645/how-to-access-sharepoint-rest-api-in-my-function-a.html Step-1 : Login to Azure Portal (https://portal.azure.com/)   Step-2 : As highlighted below, click on the  + Create a resource, and click on “Compute”. Now, choose the “Function App”.   Or, for the same Option, you can sea

Responsive design for Seattle.master in SharePoint 2013 and SharePoint Online.

/* =SharePoint Experts, Inc. - CSS for creating a responsive design for Seattle.master in SharePoint 2013 and SharePoint Online. For more details see the related blog post at http://blog.sharepointexperience.com/2015/03/making-seattle-master-responsive -Copyright SharePoint Experts, Inc. and Heather Solomon. Distributed to the public for reference and educational purposes. Code may be used as long as this copyright message stays intact. -sharepointexperience.com */ /* Font Awesome is a free font. http://fontawesome.io Check for latest version at http://fontawesome.io/get-started This should be moved to the top of your CSS file, irregardless of media queries */ @import "//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css"; @media screen and (max-width: 1044px) { /* Hide unnecessary page elements */ .ms-core-listMenu-horizontalBox .ms-listMenu-editLink  /* Global navigation "Edit Links" when managed navigation is in use */ { displa