Get all Licensed Office 365 users using PowerShell

Sometimes, we might need to view all the Licensed Users within a Office365 tenant. So here, I am going to demonstrate how to get all the users for any further analysis.

But before we delve into this plz make sure that you have all the components installed on the machine to run SharePoint Online Management Shell and  the cmdlet, Connect-MsolService. You can refer this blog post also for any assistance: https://realmpksharepoint.wordpress.com/2014/07/10/install-sharepoint-online-management-shell-on-client-side/

Following are the steps involve to perform this task:

  • Open the SharePoint Online Mangement Shell in Administrator mode.
  • Type in Connect-MsolService. When the window pops up, enter your corresponding administrator credentials.
  • If no error message is thrown then your credentials are validated.
  • In case you’re interested in getting all the available properties for the user object returned by the Get-MsolUser, then type in the cmdlet,
    Get-MsolUser | Get-MsolMember | Out-GridView
    

    The following screen will be displayed.

  • As you can see that there’s a property called isLicensed, we’re now gonna use this property in our next cmdlet to get all the Licensed Office365 users only, by running the command,
    Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" }
    

  • Finally, you can also export this information to a csv file. To do this, run this command,
    Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department, ValidationStatus | Export-Csv c:\LicensedUsers\LicensedUsers.csv
    

  • You can also view all the properties by running the command,
    Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Export-Csv c:\LicensedUsers\LicensedUsers.csv
    

The last 2 commands will not generate any message on the shell, but you can check the file at your given location.

Thanks…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s