Modify-Sublicense PowerShell function for modifying Office 365 Sublicenses


An example call would be:

Modify-Sublicense -upn "" -PrimaryLicense "TENANT:ENTERPRISEPACK -SublicensesToRemove @("SWAY","YAMMER_ENTERPRISE") -SublicensesToAdd @("SHAREPOINTENTERPRISE", "SHAREPOINTWAC")

If you’re new to powershell, scroll down past the code below for some additional tips.

Naturally, sublicenses you had before will REMAIN unless you’ve removed them.
Sublicenses you DID NOT HAVE before will NOT BE ADDED unless you specifically add them.

This is important because of how the licensing works, which has been covered in other blog posts my myself and others.

I’ve used the function below as part of a larger script with good results.


New to powershell?

Here are a few tips:

  • Since the code is a function, you’ll need to copy-paste it to a script of your own before you can use it
  • In powershell, functions need to appear in your script above/before you use them.
  • There are ways to load the function in memory, so you can call it as if it was a native command. See How to add functions to your powershell session
  • An array in powershell can have zero or 1 or many items, if you need to pass a single value, just pass it as an array with one value. That would look like this: @("Value1", "Value2")

– Jack

2 thoughts on “Modify-Sublicense PowerShell function for modifying Office 365 Sublicenses

  1. Excuse my ignorance, but when I try to run the call you have at the start of this page (Modify-Sublicense….) powershell goes to a double arrow prompt

    For example…

    PS C:\windows\system32> Modify-Sublicense -upn “” -PrimaryLi
    cense “xxxxx:STANDARDPACK -SublicensesToAdd @(“TEAMS1”, “PROJECTWORKMANAGEMENT”)
    >> (cursor flashes here)

    I tried removing the quote from the beginning of the tenant name:skuid but when I did that it returned an error stating:

    Modify-Sublicense : The term ‘Modify-Sublicense’ is not recognized as the name
    of a cmdlet, function, script file, or operable program. Check the spelling of
    the name, or if a path was included, verify that the path is correct and try

    Is “modify-sublicense” a legitimate powershell command?

    1. Hi, great question – this is the name of a function, and the code for the function is in the article.

      It’s not meant to work one off – it’s meant to be included in a script.

      If you create a ps1 file – call it jason.ps1, and copy and paste the function from the article in, and then at the end, you can call the function, using the sample as a guide, that should work for you.

Leave a Reply