msidnam
asked on
Script to add O365 E3 Licenses
I was wondering if their was an easy way to add the E3 licenses to our users, possibly through a script? We have 400 licenses that we need to add to specific users. I have a spread sheet with the user names, email addresses, etc.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you to the both of you. I needed to use ADv2 even though Adv1 didnt give me any errors. I used a combo of both your codes and ended up with the following:
$file = import-csv O365Users.csv
foreach ($user in $file){
$upn = $user.UserPrincipalName
$user2 = Get-AzureADUser -SearchString $upn
Set-AzureADUser -ObjectId $user2.ObjectId -UsageLocation US
$License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License.SkuId = "6fd2c87f-b296-42f0-b197-1e91e994b900"
$LicensesToAssign = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$LicensesToAssign.AddLicenses = $License
Set-AzureADUserLicense -ObjectId $user2.ObjectId -AssignedLicenses $LicensesToAssign
}
ASKER
Open in new window
I dont get any errors but i dont see it adding the license.