Forum Discussion
PowerShell to update License features
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
- Deleted
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
} - Zoltan BagyonSteel Contributor
There are several articles available on this topic, maybe the most thorough and comprehensive I've seen is this.
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