Assign Licenses Office 365 Through PowerShell Script


Assigning a license for a lot of users is a challenge for many customers. With this script, you will be able to assign licenses to your users based on a csv file or an Azure AD Group.



Fixed the problem to validate if Azure Active Directory is installed on your computer.
Fixed the problem when there are a lot of groups, the tool didn't show any group.
Fixed the problem to bring to the front the messages windows.
Fixed the problem with some duplicated services description.


Fixed problem when licenses are in warning status
Adapt the script to the new URL to download Windows Azure Module

Chech and install MSOnline module using the new way (Install-Module -Name MSOnline)


Microsoft .Net Framework 4.0 or higher

CSV file must contain a column with UserPrincipalName header

64-bit platform

Error handling:

Check platform version (64-bit required)

Check Execution Policy for Local Machine, if it’s not set to Unrestricted, the script will set it up by itself

Check if MSOnline Module is installed, if not it will be installed by the script

Check if you are entering credentials with the wrong format or if you are entering a wrong username or password

If you don’t have enough licenses you will be asked to assign just the available licenses and non-licensed users will be recorded in the final report

You can run the script as a test to just get the result

If a user from the csv file doesn’t exist on Office 365 you will be warned, and it will be recorded in the final report

If a user from the csv has the license, you will be asked to overwrite the user’s license (This scenario applies if you want to disable some services to the users)

A final report will be generated on your desktop called “assigned licenses.csv” for further review



Check the document "Assign Licenses Office 365.pdf" for more details


Any suggestion will be more than welcome