You are currently offline, waiting for your internet to reconnect

Your browser is out-of-date

You need to update your browser to use the site.

Update to the latest version of Internet Explorer

Getting all Licensed Office 365 users with PowerShell

About Author:

A screen shot of MVP logo

This article is provided by Office 365 MVP Rene Modery. Microsoft is so thankful that MVPs who proactively share their professional experience with other users. The article will be posted on MVP's website or Rene's blog later.
Summary
Quite often, it is required to have an overview of all the licensed users within an Office 365 tenant. Using PowerShell and the Office 365 cmdlets, it is possible to get a list of users (licensed and/or without license) for further analysis (for example for reporting purposes).
Resolution
To get started, open a SharePoint Online Management Shell, and connect to Office 365 via the cmdlet Connect-MsolService. When prompted, enter the corresponding administrator credentials.

A screen shot of SHarePoint Online Management Shell, showing the Enter Credential dialog box



To get a list of all users within your tenant (both those with licenses assigned to them and those without), you can now use the cmdlet Get-MsolUser. Execute Get-MsolUser | Get-Member | Out-GridView to get a nicely formatted list of all available properties for the user objects returned by Get-MsolUser.

A screen shot of running the Get-MsolUser. Execute Get-MsolUser | Get-Member | Out-GridView cmdlet

A screen shot of the list, showing all available properties for the user objects returned by the Get-MsolUser cmdlet


Of particular interest is the property isLicensed, which indicates whether a user has a license assigned (TRUE) or not (FALSE). It is now possible to filter the users returned by Get-MsolUser and only see those that are licensed by running the command Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" }
Note: By using "FALSE" instead of "TRUE", you can get a list of all users that do currently not have any license assigned to them.

A screen shot of all licensed users


The list of licsensed user can now be processed further, for example by exporting it to a CSV file that can be opened in Excel for reporting purposes or further analysis: Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Export-Csv c:\LicensedUsers.csv

A screen shot of exporting licensed users to Excel



Note that this exports all available properties for the licensed users. To export only specific properties, you can use the Select-Object cmdlet to specify which properties to use. As an example, only UserPrincipalName, DisplayName, Country, and Department will be exported:
Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department | Export-Csv c:\LicensedUsers.csv

A screen shot of runnning the Select-Object cmdlet

A screen shot of the export file when run the Select-Object cmdlet





Community Solutions Content Disclaimer

MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.
Properties

Article ID: 2777380 - Last Review: 09/11/2013 06:40:00 - Revision: 4.0

  • Microsoft Office 365 Enterprise preview
  • Microsoft Office 365 for enterprises
  • Microsoft Office 365 for small businesses
  • Microsoft Office 365 for government
  • Office 365 Education
  • kbgraphic KB2777380
Feedback
/html>