Skip to main content

How to display and Export information about office 365 users in office 365 by using powershell?

As an office 365 administrator, you would definitely need to display and export some user information such as distribution group list, all user list and mailboxes, license information and etc.
Most of those are cannot be manage from web portal or some are not convenient to manage on it.
So, the only way to do is "Powershell".
I've just collect some useful powershell command for displaying and exporting users information about office 365 users at below.

Display a list of office 365 Global Administrators
PowerShell command syntax: Get-MsolRoleMember –RoleObjectId .ObjectId | Select DisplayName,EmailAddress

For example  :Get-MsolRoleMember -RoleObjectId “Power Administrator”.ObjectId | Select DisplayName,EmailAddress

Display Different type of recipients with a specific Domain name (This is for the Administrator who need to administer more than one domain.)

Users UPN with a specific domain name suffix

PowerShell command syntax: Get-MsolUser –DomainName | ft -Property UserPrincipalName

For example  : Get-MsolUser -DomainName | ft -Property UserPrincipalName

Display a list of user from a specific department

PowerShell command syntax: Get-msoluser | Where {$_.Department -eq ""}

For example  : Get-msoluser | Where {$_.Department -eq "Mrkt"}

Display list of services assigned to user

PowerShell command syntax: Get-msoluser -all | ForEach-Object { "============="; $_.DisplayName; $_.licenses[0].servicestatus }

Display list of users and their currently License

PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses

Export list of users and their currently License to a file

PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses < Path & File Name>

For example : Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | select Displayname, Licenses > c:\temp folder\Licenses.txt

Export information about office 365 users mailbox to CSV file

PowerShell command syntax: Export list of all Mailboxes Get-mailbox | Export-Csv < Path & File Name>

For example : Get-mailbox | Export-Csv c:\temp folder\allmailboxes.csv

Export list of all office 365 users
PowerShell command syntax: Get-MsolUser | select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-Csv < Path & File Name>

For example : Get-MsolUser | select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-Csv c:\temp folder\allmailboxesusage.csv

Export list of all office 365 users with License
PowerShell command syntax: Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv < Path & File Name>

For example : Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv c:\temp folder\userslicenses.csv

Export list of all office 365 users without License
PowerShell command syntax: Get-MsolUser -UnlicensedUsersOnly | Export-Csv < Path & File Name>

For example : Get-MsolUser -UnlicensedUsersOnly | Export-Csv c:\temp folder\userswithoutlicense.csv

Export list of all Distribution Groups
PowerShell command syntax: Get-DistributionGroup | Export-Csv < Path & File Name>

For example : Get-DistributionGroup | Export-Csv c:\temp folder\listofdg.csv

I'll write about some more powershell commands for exchange online and other useful for office 365 if I've got time.

May you all be happy.
(Be knowledgeable, pass it on then)


  1. I have recently found an excellent Salesforce Training in India whose faculty is exceptional and you can also try this Salesforce Training and Certification in Jaipur whose syllabus is state of art. Here at Salesforce Training in Mumbai instructors are perfect to teach salesforce crm. My advice for you is to join demo at Salesforce training in Pune | Course Cost and in weekends try this best Salesforce Training in Noida | Course Cost who is providing great teaching services on Salesforce Training in Delhi and Fee Details.

  2. This is one of the best content for this topic and this is very useful for me. Thank you!
    Unix Training in Chennai
    Unix Course in Chennai
    Linux Course in Chennai

  3. mazing post thanks for sharing this click here

  4. "
    Salesforce is all about giving customers support and help. This keeps customers coming back and makes them happier and more loyal. It is different from other methods because it helps customers faster, pays attention to each customer's needs individually, and solves problems before they happen. Salesforce is one of the most influential CRM software. It supports companies to identify the potential customers for their business and collect the data to reach out to the customers securely. It also supports fixing client issues. It leads to improving the business sales and productivity. Salesforce implementation is a must for every company to grow their business. To know more about salesforce, Step into the Salesforce Training in Chennai at FITA Academy.

    For more information, Visit: Salesforce Training Online and Salesforce Training in Pondycherry | Salesforce Training in Coimbatore "

  5. The Educational Testing Service administers the "Test of English as a Foreign Language" .It is a standardized test that evaluates a person's level of English proficiency, particularly for non-native English speakers, in the areas of reading, speaking, listening, writing, and comprehension. TOEFL is an important exam for students who want to do their higher education abroad; join TOEFL Coaching in Chennai to learn more about this exam. TOEFL Coaching in Chennai

  6. SAS software is the first choice for the majority of businesses when it comes to data analytics. As a result of its features, support, and wide compatibility, SAS analytics can be simply incorporated into business operations. As a result of its visual information and data presentation, SAS is very simple for non-technical users.To learn more about SAS Software, join SAS Course in Chennai at FITA Academy.

    SAS Course in Chennai

  7. React Native was developed to make the development of mobile apps easier after ReactJS. The answer is straightforward: life is made much simpler if you can create an app once in JavaScript and release it to both Android and iOS.Using JavaScript, you can create native mobile apps with the React Native framework. To learn more about react native, join react native course in chennai at FITA Academy.
    react native course in chennai
    React native online course

  8. Any large company needs a human resources department to manage various tasks, including hiring new employees, conducting interviews, mediating conflicts, and overseeing existing employees' holiday pay, benefits, and payroll. There are several ways to enter the field of human resources. Still, the most reliable way to guarantee a job in this area is to complete an HR-specific education, such as a degree, postgraduate course, evening diploma, or online course. To learn more about human resource management, join the hr training in chennai at FITA Academy.

    hr training in chennai


  9. A popular solution for creating cross-platform mobile apps is PhoneGap.An open-source framework for developing mobile applications was produced by Nitobi Software. It enables the creation of apps utilising HTML, JavaScript, and CSS by the developers. To learn more about PhoneGap, join phonegap course in chennai at FITA Academy. phonegap course in chennai

  10. Goods and Services Tax is the name for GST. Indirect taxes like the value-added, service, purchase, excise duty, and others were replaced by this one, which was introduced to replace them all. In India, certain goods and services are subject to a tax known as GST. In India, there is only one type of tax. Join GST Classes in Chennai at FITA Academy to learn more about GST.
    GST Classes in Chennai


  11. Swift is an open-source programming language created specifically for App Store software. It has a large community of iOS developers who work hard to advance the language's native development. Swift is a potent scripting language designed specifically for iOS applications. Its extensive selection of development tools makes it perfect for creating mobile applications.
    To learn more about swift, join Swift Developer Course In Chennai at FITA Academy.

    Swift Developer Course In Chennai


Post a Comment

Popular posts from this blog

Link Aggregating with Synology NAS and Cisco Switch

I’d like to share how to setup Link Aggregating between Synology NAS and Cisco Switch. I’ve got one Synology NAS with 4 Network Ports and I’m going to use 2 of them. Both Network Port to be as one Logical Link, Fault Tolerance and Load Balancing. To do that, I need to configure Link Aggregating on Synology NAS and EtherChannel with LACP on Cisco Switch. Below is brief steps to do to meet with my requirements. - Get connected Synology NAS and Cisco Switch as shown in picture. - Bonding two Network Ports of Synology NAS and assign IP Address - Configure EtherChannel with LACP in Cisco Switch and add two physical ports as Member. OK. Let’s begin from Synology NAS. - Login to the Synology and go to Control Panel>Network>Create>Create Bond - Select IEEE 802.3ad to get Fault Tolerance and Load Balancing Featureyou’re your switch not support 802.3ad you can only select Fault Tolerance only feature). After that click “Next”. - Choose the network port f

Fortigate guide for Begineer - 6

I would like to explaine how to troubleshoot the Fortigate Unit configured by Transparent Mode in step by step this time. Let's assume, you have one Fortigate Unit that configured as Transparent Mode. But devices from Internal/Private Network unable to access Internet/Public Network through your Fortigate Unit. OK. Let's troubleshoot with following steps, 1) Check the physical network connections between the network and the FortiGate unit, and between the FortiGate unit and the Internet. 2) Check the router and ISP-supplied equipment to make sure it is operating correctly. 3) Verify that you can connect to the internal interface by connecting to the management IP address of the FortiGate unit from the Internal network. From the internal network, attempt to ping the management IP address. If you cannot connect to the internal interface, verify the IP configuration of the PC and make sure the cables are connected and all switches and other devices on the network are powered on a

How to check the vpn user list and session in Cisco ASA 5520?

You've deployed Cisco ASA Firewall and setup Local AAA Server to create useraccount for IPSec VPN usage. As a network administrator, you've responsibility to check and monitor the list of vpn user and active session for security and audit purpose. You can use ASDM GUI to do such task but its handy to do. So, it is better to user CLI for that. Below are some useful commands to check user list and active vpn user sessions. To check user list, use below commands - show run | grep username - show aaa local user To check active vpn user list and sessions, use below commands - show vpn-sessiondb remote | grep Username (This command result will let you know how many user are active) - show vpn-sessiondb remote filter name username (This filter command will let you know details of vpn session user by inserting active vpn username in "username" ) Yes. That's all. Here I show you with Cisco ASA 5520 and its software version is 8.2 (5). May