Powershell: Possible to add multiple licences with import csv and -LicenseAssignment paramater?

Rens Sergier 1 Reputation point
2021-04-03T17:37:47.397+00:00

Hello

I just created my own script to automate some things.
I have just one question that I can't solve:

This is my csv:

UserPrincipalName,DisplayName,Password,UsageLocation,LicenseAssignment
Sandrine@emic.be,Sanne,Voka545464,be,

my command:

addpath = "C:\Users\rens.sergier\Desktop\addusers.csv"

import-csv $addpath | foreach { New-Msoluser -UserPrincipalName $.UserPrincipalName -Displayname $.displayname -Password $.Password -UsageLocation $.UsageLocation -LicenseAssignment $_.LicenseAssignment -ForceChangePassword $false}

If i do it with 1 LicenseSku it worked fine but I want to find a way when it is also possible to assign more than 1 licencse to an user.

I tried with an array in my csv file but that did not work

Can anybody help me?

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,643 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 20,516 Reputation points Microsoft Employee
    2021-04-05T22:46:32.593+00:00

    One option would be to assign the licenses to a group and then assign users to that group, or use dynamic group membership.

    There is also a sample in this blog post that goes through and creates a custom license SKU, and assigns the licenses in bulk to the users. In this solution the admin disabled the license plans that he didn't want to be available to his users.

    No comments