SOLVED

license

%3CLINGO-SUB%20id%3D%22lingo-sub-736883%22%20slang%3D%22en-US%22%3Elicense%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-736883%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3EI%20want%20assign%20EMS%20license%20to%20100%20users%20and%20my%20users%20are%20in%20text%20file.%20The%20text%20file%20format%20is%20below.%20Will%20the%20below%20syntax%20work%20for%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3Euser%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Euser1%40abc.com%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Euser2%40abc.com%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24LIC%20%3D%20New-MsolLicenseOptions%20-AccountSkuId%20%22abc%3AEMS%22%20-DisabledPlans%20%22Service1%22%2C%22Service2%22%2C%22Service3%22%3CBR%20%2F%3E%24userlist%20%3D%20Get-Content%20-Path%20%22C%3A%5Cmyusers.txt%22%3CBR%20%2F%3Eforeach%20(%24user%20in%20%24userlist)%7B%3CBR%20%2F%3ESet-MsolUser%20-UserPrincipalName%20%24user%20-UsageLocation%20%22United%20Kingdom%22%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24user%20-AddLicenses%20%22abc%3AEMS%22%20-LicenseOptions%20%24LIC%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-736883%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHybrid%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOn-Premises%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-736961%22%20slang%3D%22en-US%22%3ERe%3A%20license%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-736961%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F139420%22%20target%3D%22_blank%22%3E%40Rising%20Flight%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20will%20work!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

Hi All

I want assign EMS license to 100 users and my users are in text file. The text file format is below. Will the below syntax work for me.

 

user

user1@abc.com

user2@abc.com

 

$LIC = New-MsolLicenseOptions -AccountSkuId "abc:EMS" -DisabledPlans "Service1","Service2","Service3"
$userlist = Get-Content -Path "C:\myusers.txt"
foreach ($user in $userlist){
Set-MsolUser -UserPrincipalName $user -UsageLocation "United Kingdom"
Set-MsolUserLicense -UserPrincipalName $user -AddLicenses "abc:EMS" -LicenseOptions $LIC
}

 

1 Reply
Highlighted
Best Response confirmed by Rising Flight (Frequent Contributor)
Solution

@Rising Flight 

 

That will work!