PowerShell to update License features

%3CLINGO-SUB%20id%3D%22lingo-sub-43321%22%20slang%3D%22en-US%22%3EPowerShell%20to%20update%20License%20features%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-43321%22%20slang%3D%22en-US%22%3E%3CP%3ELooking%20for%20a%20way%20to%20update%20the%20features%20for%20our%20E3%20licensed%20users.%20Setting%20them%20initially%20is%20no%20problem%20but%20we%20have%20not%20found%20a%20way%20to%20update%20someone%20that%20already%20has%20an%20E3.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20user%20A%20has%20an%20E3%20but%20only%26nbsp%3B%20the%20%22SharePoint%20Online%22%20feature%20on%20and%20we%20need%205%20other%20features%20enabled.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestions%20would%20be%20much%20appreciated!%3C%2FP%3E%3CP%3Ee%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-43321%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%20Commands%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-46983%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20to%20update%20License%20features%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-46983%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20not%20sure%20if%20you%20managed%20to%20solve%20this%2C%20but%20I%20wrote%20a%20couple%20powershell%20functions%20that%20might%20help.%20I%20wasn't%20having%20a%20good%20time%20trying%20to%20re-assign%20licenses%20to%20users%20as%20we%20don't%20enable%20all%20features%20of%20a%20license.%20I%20found%20it%20easier%20to%20just%20remove%20all%20the%20licenses%20and%20re-assign%20them.%20that%20way%20I%20knew%20exactly%20which%20licenses%20they%20had.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20first%20is%20a%20function%20to%20clear%20the%20license%20for%20the%20user%20and%20the%20second%20function%20clears%20the%20licenses%20and%20then%20assigns%20the%20specific%20licenses%2C%20with%20the%20options%20that%20we%20chose.%20I%20hope%20it%20helps!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23%20Removes%20all%20O365%20Licenses%3CBR%20%2F%3E%23%20Accepts%20UPN%3CBR%20%2F%3E%23%20Returns%20Nothing%3CBR%20%2F%3Efunction%20Remove-O365Licenses%20(%24upn)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23%20Get%20user%20info%20from%20O365%3CBR%20%2F%3E%24userInfo%20%3D%20Get-MsolUser%20-UserPrincipalName%20%24upn%3C%2FP%3E%3CP%3E%23%20Clear%20any%20existing%20licenses%3CBR%20%2F%3Eif%20(%24userInfo.isLicensed%20-eq%20%24true)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eforeach%20(%24sku%20in%20(%24userInfo%20%7C%20select%20-ExpandProperty%20licenses))%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23Write-Host%20%22Removing%20License%3A%20%22%20%24sku.AccountSkuId%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24upn%20-RemoveLicenses%20%24sku.AccountSkuId%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23%20Clears%20previous%20license%20and%20sets%20correct%20Office%20365%20Staff%20license%3CBR%20%2F%3E%23%20Accepts%20UPN%3CBR%20%2F%3E%23%20Returns%20nothing%3CBR%20%2F%3Efunction%20Set-O365StaffLicense%20(%24upn)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23%20Set%20SKU%20options%20for%20staff%3CBR%20%2F%3E%24O365SkuStaff1%20%3D%20New-MSOLLicenseOptions%20-AccountSkuID%20%22lethsd51%3APROJECTONLINE_PLAN_1_FACULTY%22%20-DisabledPlans%20SHAREPOINTWAC_EDU%3CBR%20%2F%3E%24O365SkuStaff2%20%3D%20New-MSOLLicenseOptions%20-AccountSkuID%20%22lethsd51%3ASTANDARDWOFFPACK_FACULTY%22%20-DisabledPlans%20EXCHANGE_S_STANDARD%2CSHAREPOINTSTANDARD_EDU%3CBR%20%2F%3E%24O365SkuStaff3%20%3D%20New-MSOLLicenseOptions%20-AccountSkuID%20%22lethsd51%3AOFFICESUBSCRIPTION_FACULTY%22%20-DisabledPlans%20SWAY%2CSHAREPOINTWAC_EDU%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Get%20user%20info%20from%20O365%3CBR%20%2F%3E%24userInfo%20%3D%20Get-MsolUser%20-UserPrincipalName%20%24upn%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Host%20%22Processing%20%24upn%22%3CBR%20%2F%3E%23%20Set%20usage%20location%3CBR%20%2F%3Eif%20(%24userInfo.UsageLocation%20-eq%20%24null)%3CBR%20%2F%3E%7B%3CBR%20%2F%3ESet-MsolUser%20-UserPrincipalName%20%24upn%20-UsageLocation%20CA%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Remove%20All%20Current%20Licenses%3CBR%20%2F%3ERemove-O365Licenses%20(%24upn)%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Apply%20licenses.%20The%20order%20of%20these%20matter!%3CBR%20%2F%3EWrite-Host%20%22Setting%20License%3A%20Project%20Online%20for%20Faculty%22%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24upn%20-AddLicenses%20lethsd51%3APROJECTONLINE_PLAN_1_FACULTY%20-LicenseOptions%20%24O365SkuStaff1%3CBR%20%2F%3EWrite-Host%20%22Setting%20License%3A%20Office%20365%20Education%20for%20Faculty%22%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24upn%20-AddLicenses%20lethsd51%3ASTANDARDWOFFPACK_FACULTY%20-LicenseOptions%20%24O365SkuStaff2%3CBR%20%2F%3EWrite-Host%20%22Setting%20License%3A%20Office%20365%20ProPlus%20for%20Faculty%22%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24upn%20-AddLicenses%20lethsd51%3AOFFICESUBSCRIPTION_FACULTY%20-LicenseOptions%20%24O365SkuStaff3%3CBR%20%2F%3EWrite-Host%20%22Setting%20License%3A%20Exchange%20Online%20Plan%202%20for%20Faculty%22%3CBR%20%2F%3ESet-MsolUserLicense%20-UserPrincipalName%20%24upn%20-AddLicenses%20lethsd51%3AEXCHANGEENTERPRISE_FACULTY%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-44722%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20to%20update%20License%20features%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-44722%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20need%20to%20use%20New-MsolLicenseOptions%20cmdlet%20to%20achieve%20this.%20Check%20the%20below%20document%20for%20samples.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Flibrary%2Fdn771769.aspx%3Ff%3D255%26amp%3BMSPPError%3D-2147217396%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Flibrary%2Fdn771769.aspx%3Ff%3D255%26amp%3BMSPPError%3D-2147217396%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20you%20can%20use%20the%20below%20one%20from%20TechNet%20Gallery.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2FOffice365-License-cfd9489c%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2FOffice365-License-cfd9489c%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-43344%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20to%20update%20License%20features%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-43344%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20are%20several%20articles%20available%20on%20this%20topic%2C%20maybe%20the%20most%20thorough%20and%20comprehensive%20I've%20seen%20is%20%3CA%20href%3D%22https%3A%2F%2Fmattmcnabb.github.io%2FOffice-365-Licensing_1%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

Looking for a way to update the features for our E3 licensed users. Setting them initially is no problem but we have not found a way to update someone that already has an E3.

 

So user A has an E3 but only  the "SharePoint Online" feature on and we need 5 other features enabled.

 

Any suggestions would be much appreciated!

e

3 Replies
Highlighted

There are several articles available on this topic, maybe the most thorough and comprehensive I've seen is this

Highlighted

You need to use New-MsolLicenseOptions cmdlet to achieve this. Check the below document for samples.

https://technet.microsoft.com/en-us/library/dn771769.aspx?f=255&MSPPError=-2147217396

 

Or you can use the below one from TechNet Gallery.

https://gallery.technet.microsoft.com/Office365-License-cfd9489c

 

 

Highlighted

I'm not sure if you managed to solve this, but I wrote a couple powershell functions that might help. I wasn't having a good time trying to re-assign licenses to users as we don't enable all features of a license. I found it easier to just remove all the licenses and re-assign them. that way I knew exactly which licenses they had. 

 

The first is a function to clear the license for the user and the second function clears the licenses and then assigns the specific licenses, with the options that we chose. I hope it helps!

 

# Removes all O365 Licenses
# Accepts UPN
# Returns Nothing
function Remove-O365Licenses ($upn)
{
# Get user info from O365
$userInfo = Get-MsolUser -UserPrincipalName $upn

# Clear any existing licenses
if ($userInfo.isLicensed -eq $true)
{
foreach ($sku in ($userInfo | select -ExpandProperty licenses))
{
#Write-Host "Removing License: " $sku.AccountSkuId
Set-MsolUserLicense -UserPrincipalName $upn -RemoveLicenses $sku.AccountSkuId
}
}
}

 

# Clears previous license and sets correct Office 365 Staff license
# Accepts UPN
# Returns nothing
function Set-O365StaffLicense ($upn)
{
# Set SKU options for staff
$O365SkuStaff1 = New-MSOLLicenseOptions -AccountSkuID "lethsd51:PROJECTONLINE_PLAN_1_FACULTY" -DisabledPlans SHAREPOINTWAC_EDU
$O365SkuStaff2 = New-MSOLLicenseOptions -AccountSkuID "lethsd51:STANDARDWOFFPACK_FACULTY" -DisabledPlans EXCHANGE_S_STANDARD,SHAREPOINTSTANDARD_EDU
$O365SkuStaff3 = New-MSOLLicenseOptions -AccountSkuID "lethsd51:OFFICESUBSCRIPTION_FACULTY" -DisabledPlans SWAY,SHAREPOINTWAC_EDU

# Get user info from O365
$userInfo = Get-MsolUser -UserPrincipalName $upn

Write-Host "Processing $upn"
# Set usage location
if ($userInfo.UsageLocation -eq $null)
{
Set-MsolUser -UserPrincipalName $upn -UsageLocation CA
}

# Remove All Current Licenses
Remove-O365Licenses ($upn)

# Apply licenses. The order of these matter!
Write-Host "Setting License: Project Online for Faculty"
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:PROJECTONLINE_PLAN_1_FACULTY -LicenseOptions $O365SkuStaff1
Write-Host "Setting License: Office 365 Education for Faculty"
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:STANDARDWOFFPACK_FACULTY -LicenseOptions $O365SkuStaff2
Write-Host "Setting License: Office 365 ProPlus for Faculty"
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:OFFICESUBSCRIPTION_FACULTY -LicenseOptions $O365SkuStaff3
Write-Host "Setting License: Exchange Online Plan 2 for Faculty"
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses lethsd51:EXCHANGEENTERPRISE_FACULTY
}