PHPKB Knowledge Base Software Logo  
Guru Corner
Online Knowledgebase System  
Knowledge Base Home Knowledge Base Home
Home > All Categories > Microsoft > Exchange > Office 365 > Getting all Licensed Office 365 users with PowerShell
Question Title Getting all Licensed Office 365 users with PowerShell

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.

 


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.

 


 

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.

 

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

 

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

 

 
 



Authored by: Guru Corner
Click Here to View all the questions in Office 365 category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
Article Information Additional Information
Article Number: 301
Created: 2013-07-07 7:39 PM
Rating: No Rating
 
Article Options Article Options
Print Question Print this Question
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
 
Search Knowledge Base Search Knowledge Base
 
 

Powered by Guru Corner