Set-MsolUserLicense -RemoveLicense Issue

Welcome Forums General PowerShell Q&A Set-MsolUserLicense -RemoveLicense Issue

This topic contains 1 reply, has 2 voices, and was last updated by

10 months, 3 weeks ago.

  • Author
  • #103474

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    I am trying to an-assign a bulk of user's licenses from our Office365.

    I have all of the user's UserPrincipalName on a CSV file like so:

    That is what I tried to do:

    $csv1 = import-csv | select -expandProperty name
    Set-MsolUserLicense -UserPrincipalName $csv1 -RemoveLicense "domain:STANDARDPACK"

    When I had only ONE user on the CSV file, IT WORKED! But when I tried to add more users to the exact file and in the exact same list, the command fails and give me this 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 doubled checked and made sure it is indeed the correct license (domain:StandartPack)

    What else can I do? How can I make it work?


  • #103478

    Topics: 2
    Replies: 915
    Points: 1,533
    Helping Hand
    Rank: Community Hero

    You are not looping through the user list in the CSV file.
    $csv1 is not a use name, it's a lot of user names and you can only pass one name at a time.

    # Collect all the user names to provision
    $csv1 = import-csv | select -expandProperty name
    # step through each user and take actions needed.
    ForEach($MSOUser in $csv1)
        # your code here'

    There is a script on the MS that does this. See if that can replace the effort you are trying.

    Bulk license assignment to Office 365 users based on CSV

    If you have directory synchronization in place, your identities get provisioned in Office 365 without a license. You can use this script to bulk-add the licenses to the users based on a CSV file.


    There are other approaches, depending on how you need to do this.

    How to Use PowerShell to Automatically Assign Licenses to Your Office 365 Users

    Bulk assign custom Office 365 licenses via Powershell

    Bulk Assign Licenses in Office 365 Using PowerShell

    Assign licenses to user accounts with Office 365 PowerShell

The topic ‘Set-MsolUserLicense -RemoveLicense Issue’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort