Back to script samples page
Export a list of non-licensed users into a CSV file

To export the results of the non-licensed users into a CSV file run the following command. You can replace the C:\reports\non-licensed_users.csv with a location and file name of your choosing.

#Export a list of non-licensed users into a CSV file.

#Connecting to Azure Active Directory

#This first command will import the Azure Active Directory module into your PowerShell session.
Import-Module MSOnline

#Capture administrative credential for future connections.
$credential = get-credential

#Establishes Online Services connection to Azure Active Directory  
Connect-MsolService -Credential $credential

#Export first 10,000 unlicensed users to CSV file at C:\reports\non-licensed_users.csv
Get-MsolUser -maxresults 10000 –UnlicensedUsersOnly | export-csv C:\reports\non-licensed_users.csv
Downloaded 0 times
* * * - - (1)
Comments

No Comments