Managing Office 365 licenses with PowerShell

 

In my never ending quest to make Office 365 migrations as simple as possible for myself, I have written a PowerShell script that should make Office 365 license management easier. Version 1.0 of Manage-Office365Licenses is available on the TechNet Gallery. My goal with this script is to provide a simple interface that will assist administrators in bulk assigning Office 365 licenses to user accounts.

When launching this script, you will first be asked to enter your Office 365 Global Administrator credentials. After entering your credentials, you’re PowerShell session will be connected to Azure Active Directory for your tenant and you’ll see the top level menu.

From this menu you’ll have the following five options; Display a list of licenses available in your tenant, Assign usage location, Assign licenses, Remove licenses, and Exit.

Selecting option 1 will display a list of licenses available in your tenant that looks like this

Here you can see the licenses I have in my tenant; a single Exchange license (MCSMLab is not exactly a money making machine, and these licenses are not free). You can also see that the option to open a separate window showing these licenses is there. This will open a notepad window with the same information you see here in PowerShell. This option is there so you can copy and paste specific licenses into the other functions in this script. Making your choice here will return you to the top level menu.

The second option for the top level menu is to Assign usage location. Before you can assign licenses, you need to assign a usage location to your users.

For most tenants, you’ll want to assign the same usage location to all of your users in this tenant. If that is not the situation for you, there are three other options to assign licenses to different sub-sets of your users; Assign by group, Assign by search string, and Assign to a specific user. Selecting any of the options will ask you to enter a country code to assign.

After entering your country code, you’ll be asked for either the group, search string, or users UPN of the script will just proceed if you are assigning this country code to all users in your tenant. Once that action is complete, you’ll be returned to the top level menu.

The other two options from the main menu, assign and remove licenses, have exactly the same options as the assign usage location sub-menu.

That pretty well covers the script. If you have any suggestions for improvements I can add to this script, please let me know.

 

Nathan OBryanComment