Forum Discussion
Powershell to add apps to a licensed user
- Apr 24, 2020
Sahin Boluk Here is the PowerShell I used to re-enable all the features for the users with Office 365 E3 licenses in our tenant:
Connect-AzureAD $license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense $licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses $license.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value "ENTERPRISEPACK" -EQ).SkuID $licenses.AddLicenses = $license Get-AzureAdUser -All $true | foreach {if (($_.AssignedLicenses).SkuID -contains $license.SkuID) {Set-AzureAdUserLicense -ObjectID $_.UserPrincipalName -AssignedLicenses $licenses}}You could modify it to only enable a selection of features by setting the DisabledPlans property of the $license object as shown here: https://docs.microsoft.com/en-us/powershell/azure/active-directory/enabling-licenses-sample?view=azureadps-2.0
I would recommend Group based licensing as a nice and simple method to achieve what you want. You can read about it here - https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-licensing-whatis-azure-portal and here - https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-groups-assign
Really nice way to control your licences.
- Sahin BolukApr 24, 2020Copper Contributor
Thank you Peter. This is something we can definitely look into going forward, but does look like some setup is required to "migrate" all of the 400+ users we have on MS Teams so far from Direct assignment to Group assignment.
- PeterRisingApr 25, 2020MVP
Is your script something along the lines of the below? Does removing Stream from the DisabledPlans and then running against your csv file not have the desired effect?
Connect-MsolService
$LO = New-MsolLicenseOptions -AccountSkuId "reseller-account:ENTERPRISEPACK" -DisabledPlans "SWAY", "FLOW_O365_P2", "POWERAPPS_O365_P2", "YAMMER_ENTERPRISE"
import-csv '.\test.csv' | foreach {
Set-MsolUser -UserPrincipalName $_.UserPrincipalName -usagelocation 'GB'
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses reseller-account:ENTERPRISEPACK -LicenseOptions $LO}Maybe try this with a csv with one test user first to see if it works for you. This is one I ran quite some time ago now and I've not had the chance to test it for you myself just yet. Will have a look if I get the chance.
- Ryan SteeleApr 24, 2020Bronze Contributor
Sahin Boluk Here is the PowerShell I used to re-enable all the features for the users with Office 365 E3 licenses in our tenant:
Connect-AzureAD $license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense $licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses $license.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value "ENTERPRISEPACK" -EQ).SkuID $licenses.AddLicenses = $license Get-AzureAdUser -All $true | foreach {if (($_.AssignedLicenses).SkuID -contains $license.SkuID) {Set-AzureAdUserLicense -ObjectID $_.UserPrincipalName -AssignedLicenses $licenses}}You could modify it to only enable a selection of features by setting the DisabledPlans property of the $license object as shown here: https://docs.microsoft.com/en-us/powershell/azure/active-directory/enabling-licenses-sample?view=azureadps-2.0