Export Office365 users along with assigned licenses to CSV

Here is a small PowerShell script to Export all users in your tenant along with the licenses assigned to them in O365.

To Execute this you must have MSOL  PowerShell module installed which you can install by running following command

Install-Module MSOnline

Once its installed run following script

#Establish a PowerShell session with Office 365. You'll be prompted for your Delegated Admin credentials

if (!$UserCredential)
{
$UserCredential = Get-Credential
}

Connect-MsolService -Credential $UserCredential

Get-MsolUser -All | select DisplayName,USerprincipalname,islicensed,{$_.Licenses.AccountSkuId} | Export-CSV C:\<FileName>.csv

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s