The Joker
The Joker

Reputation: 402

Office 365 license not assigned using new-msoluser

I have a Powershell (5.0) script that imports a CSV file and creates new Office 365 users. The accounts are being created correctly, however the specified license is not being applied.

My script:

Import-Csv -Path C:\Temp\tmp9DBC.csv | %{ New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $_.UserPrincipalName -City $_.City -Country $_.Country -Department $_.Department -FirstName $_.FirstName -LastName $_.LastName -ForceChangePassword:$True -UsageLocation $_.Location -Password $_.Password -PasswordNeverExpires:$True -State $_.State -Title $_.Title -LicenseAssignment $_.License}

All other properties are assigned correctly, but all of my users show isLicensed = false.

Assigning the license manually works fine, so I know that the SKU is good. Why is it not being applied?

EDIT: Sample entry from CSV file as requested:

ADULTMAN Vincent,[email protected],MyCity,MyCountry,Library and Information Services,Vincent,Adultman,"xxxxxxxxxxxxxx:STANDARDWOFFPACK_IW_FACULTY",Jaom3231,WA,Library Assistant

Upvotes: 1

Views: 309

Answers (1)

Hemant Kabra
Hemant Kabra

Reputation: 884

While using Import-Csv power shell command you must make sure that you are using the same column name which are mentioned in the csv file.

As your csv file contains column AccountType for licensing details, so please replace your existing powershell command with this:

Import-Csv -Path C:\Temp\tmp9DBC.csv | %{ New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $_.UserPrincipalName -City $_.City -Country $_.Country -Department $_.Department -FirstName $_.FirstName -LastName $_.LastName -ForceChangePassword:$True -UsageLocation $_.Location -Password $_.Password -PasswordNeverExpires:$True -State $_.State -Title $_.Title -LicenseAssignment $_.AccountType}

Hope this will help you.

Upvotes: 1

Related Questions