One of the more tedious tasks in Office 365 is setting the user usage location. This is a requirement prior to licensing. In large, global organizations, you may have multiple usage locations that you need to set. This script is based on the ISO country code list and will allow you to set the country code in Active Directory and then configure the user's corresponding Windows Azure Active Directory ID with the same usage location.
Office 365 Tenant
Directory Synchronization Activated and Configured
Active Directory country code field updated for users
It has two operating modes--report and update. Report will show you user-by-user what it was able to detect as the country code and what will need to be set. Update will make the changes. Users with no country code will appear in red.
Alternately, if you have upgraded to AADConnect, check out my blog post on using an AADConnect sync rule to fill in this data at https://www.undocumented-features.com/2016/07/22/use-aadconnect-to-populate-office-365-usage-location/.