Assigning Office 365 Licence with Powershell - Error RRS feed

  • Question

  • Im trying to add an Office365 licence to a user with powershell and get an error:

    Set-MsolUserLicense : Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses.

    I can connect to the tenant and retrieve licences successfully with Get-MsolAccountSku and have plenty available.

    AccountSkuId                         ActiveUnits WarningUnits ConsumedUnits
    ------------                         ----------- ------------ -------------          
    reseller-account:STANDARDPACK        162         0            154

    User does not currently have a licence assigned.

    Script i am running is:

    $license = "tenantname:STANDARDPACK"
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $license -DisabledPlans POWERAPPS_O365_P1
    Set-MsolUserLicense -UserPrincipalName "" -AddLicenses $license -LicenseOptions $LicenseOptions

    Tuesday, February 5, 2019 1:16 AM