Skip to main content

Power Shell command To get All users from SharePoint Online and Office 365








1) Please connect your Online Environment First

Commands : 

Open Windows PowerShell as an administrator (use Run as administrator).

Run these commands to connect to Office 365.

$credential = Get-Credential
Import-Module MsOnline
Connect-MsolService -Credential $credential
Connect-SPOService -Url https://domainhost-admin.sharepoint.com -credential $credential
Import-Module LyncOnlineConnector

$sfboSession = New-CsOnlineSession -Credential $credential

Import-PSSession $sfboSession



Run Below command to get All users :

Get-MSOLUser- All | Select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-CSV C://MOSuser.csv

Good Luck !

Comments