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