A simple script to export a list of licenced users from your M365 tenant:
Get-MSOLUser | Where-Object { $_.isLicensed -eq “True”} | Select-Object DisplayName, UserPrincipalName, isLicensed | Export-Csv C:\Temp\365LicencedUserList.csv
Note that this does not work automatically within the Exchange Online Powershell module you may have previously downloaded. You firstly need to run Powershell as admin and install the MS Azure AD module for Powershell, Install-Module MSOnline, install NuGet and PSGallery if prompted, you can then connect by running Connect-MSOLService. You can then run the command above to export the data.