license

%3CLINGO-SUB%20id%3D%22lingo-sub-736881%22%20slang%3D%22en-US%22%3Elicense%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-736881%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-736881%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-737050%22%20slang%3D%22en-US%22%3ERe%3A%20license%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-737050%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%3CLINGO-SUB%20id%3D%22lingo-sub-737656%22%20slang%3D%22en-US%22%3ERe%3A%20license%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-737656%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%3Bsince%20you%20want%20to%20assign%20EM%2BS%20Licenses.%20You%20could%20also%20use%20group-based%20licensing.%20Saves%20you%20the%20hassle%20of%20using%20Powershell%20and%20is%20more%20dynamic.%20But%20as%20previously%20stated%20your%20code%20would%20work%20but%20would%20need%20to%20be%20run%20every%20time%20you%20want%20to%20add%20another%20user.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Flicensing-groups-assign%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Flicensing-groups-assign%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FViktor%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
}

 

2 Replies
Highlighted

@Rising Flight 

 

That will Work!

Highlighted

@Rising Flight since you want to assign EM+S Licenses. You could also use group-based licensing. Saves you the hassle of using Powershell and is more dynamic. But as previously stated your code would work but would need to be run every time you want to add another user.

 

https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-groups-assign

 

/Viktor