Provisioning O365 user Licenses

At the end of the encore webinar I led today, we had composed a little function. Well I was doing the typing and talking, but thanks to all who attended the webinar live!

Set-ACMEO365UserLicense function in PowerShell
Set-ACMEO365UserLicense function in PowerShell

One of the lovely embarrassing things that can come up in a live webinar did. I was typing this function (and about eight prior lines apparently) toward the end of the webinar. I had a typo on line 91. Instead of $oneLicense I had $license as the parameter to the Add method. So the function didn’t work when I was doing the demo. Sorry about that. But as soon as I people departed and I ended the Zoom Webinar session, I saw the problem. I fixed it before making the screenshot above and the function works.

Note that there are a few other little magic ingredients needed before running the function, such as logging into AzureAD with user admin or global admin privileges using Connect-AzureAD. Please let me know if you have any questions or comments on this.

Here is a text version of that function definition.

function Set-ACMEO365UserLicense {
    param( $Name, $TemplateName = "Samantha" )
    $template = Get-AzureADUser -SearchString $TemplateName 
    # or could create license objects from scratch
    $licenses = New-Object Microsoft.Open.AzureAD.Model.AssignedLicenses 
    $licenses.AddLicenses = @()    # empty array (list)
    $template.AssignedLicenses | ForEach-Object {    # walk through the existing "template" user's licenses
        $oneLicense = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
        $oneLicense.SkuId = $_.SkuId   # copies one product code from existing user
        $licenses.AddLicenses.Add( $oneLicense )    # void Add(Microsoft.Open.AzureAD.Model.AssignedLicense item)  
    $u = Get-AzureADUser -SearchString $Name 
    Set-AzureADUserLicense -ObjectId $u.ObjectId -AssignedLicenses $licenses

I hope this is helpful. Thank you!

Encore Webinar and AZ-900 Course

Hello! I would like to share news of two events this week. If you know anyone who might be interested in attending, please feel free to share the word.

  1. An “Encore Presentation” of the webinar I ran on August 30.
  2. A one day course on Azure Fundamentals.

Both events are running this week—the one hour webinar on Thursday, and the full day course on Friday. The webinar is free.

Topic: Encore Presentation: Provisioning Microsoft Cloud User Licenses With PowerShell 

You are invited to a Zoom webinar.

When: Thursday, September 19, 2019 14:00 (02:00 PM) Arizona 
14:00 PDT (Los Angeles)
15:00 MDT (Denver)
16:00 CDT (Dallas)
17:00 EDT (New York)
21:00 UTC [see in other time zones]

Please attend this free one hour live online webinar in which Brad Werner presents techniques, tips, and tricks for using PowerShell to administer Azure Active Directory user accounts so that they are licensed for cloud services within Microsoft 365 subscriptions such as Office 365 (O365), the Microsoft Enterprise Mobility + Security (EMS) Suite, and Windows as a Service (WaaS). Come with questions. The session will start with an overview, focus on demonstration in PowerShell, and hopefully end with some time for questions. 

NOTE: This is an encore presentation of the same topic covered on 2019-08-30. (note: the email invitation incorrectly stated that the earlier webinar was 2019-09-30, but I assure you it was in August, as I have not yet mastered the secrets of time travel. Yet.) Several people who had been unable to attend the one on August 30 had asked if it had been recorded, which it had not, so I wanted to offer it again. Knowing how things go, it will likely be different the second time, based on questions or comments people may have and other factors.

Register in advance for this webinar

After registering, you will receive a confirmation email containing information about joining the webinar. 

Upcoming Course: AZ-900 Microsoft Azure Fundamentals @ Friday, September 20, 2019: 

NOTE ALSO: Brad will be teaching a regular one-day live online course on Friday, September 20: AZ-900 Microsoft Azure Fundamentals. For further information and enrollment please visit: <>


Webinar Speakers 

Brad Werner (Technical Evangelist @Werner Training and Consulting, Inc.) 
Brad Werner is a software engineer, technical trainer, and cloud and infrastructure architect specializing in automation, networking, mobility, and security. Brad is a Microsoft Certified Trainer (MCT), and is also certified by Microsoft as a Microsoft 365 Enterprise Administrator Expert, Azure Solutions Architect Expert, MCSE (Windows Server 2016 and Cloud Infrastructure), and at an associate level as Azure Administrator, Azure Developer, and Modern Desktop Administrator. He has written several training courses including courses on Windows Server, Security, Systems Hardening, and PowerShell. Brad brings his extensive software engineering experience with UNIX, MacOS, and embedded systems as well as Microsoft technologies to his training and consulting adventures. He has been teaching PowerShell for eleven years.