Resize group-based licensed Cloud PC with PowerShell

By | June 4, 2022

Introduction

Resizing a Windows 365 Enterprise Cloud PC is very easy and can be done directly within the MEM portal. I like this feature and how seamless it’s working. However, we cannot resize our Cloud PC if we have assigned the license through group-based licensing.
Group-based licensing is a must to gain better visibility and control of your licenses. Therefore it’s a big issue if you ask me.

This article will go through the process of resizing a group-based licensed Cloud PC with a PowerShell script I have created to simplify things a bit.

The resize error

When trying to resize a Cloud PC with the MEM portal when the Windows 365 license is assigned through a group-based license, The error below will be displayed. As Microsoft has stated in their documentation, Resizing isn’t supported for Cloud PCs provisioned through group-based licenses.

The manual workaround

You can still resize your Cloud PC. You need to take some additional steps for it to work.

  1. Remove User from current license group.
  2. Add the current Cloud PC license size directly to the user.
  3. Go to the MEM portal and resize.
  4. Wait for the resize to be completed.
  5. Remove the new directly assigned Cloud PC license from the user.
  6. Add the user to the new license group.

Even though the above method works, it’s not an ideal way to handle a resize.

The PowerShell script

To simplify things, I have created a PowerShell script. It does the same thing as the steps above but also does a lot of pre-requirements checks before the actual resizing is started. I will not go through all the 500+ lines in the script as we all might fall asleep by its end. But I will go through the most important things to know.

Thanks to Donna Ryan for publishing sample scripts on how to connect to Windows 365. This gave me a nice template to start with. Check them out here on Github.

Down-sizeing a Cloud PC

Before we go and look at the script in action, I have discovered an interesting thing about resizing. When resizing in the MEM portal, I cannot choose a smaller size than the one the Cloud PC has. E.g going from 2vCPU, 8GB, 128GB to 2vCPU, 4GB, 128GB is not possible. so I’m only able to scale up and not down. Choosing a smaller size in the script will down-size the Cloud PC. I have only tested this with the down-sizing of the Ram. The script will return the resizing as “completed” however, the Cloud PC size is not changed, but it will automatically attempt a resize again. Eventually, it will down-size the Cloud PC. Feel free to down-size your Cloud PC with the script, but it seems a bit shaky, and make sure to test out your specific scenario before using it on a Cloud PC in Production.

Using the script is at your own risk.

The script in action

To show how it works, I will resize my test user Cloud PC from 2vCPU, 4GB, 128 GB to 2vCPU, 8GB, 128GB. I have the following license group configured.

LicensGroup-Windows365Enterprise-2vCPU-4GB-128GB

LicensGroup-Windows365Enterprise-2vCPU-8GB-128GB

The user is a member of LicensGroup-Windows365Enterprise-2vCPU-4GB-128GB and has no direct Windows 365 license assigned. The user has a Cloud PC named CPC-cn-P3NRP-F0 that we will be resizing.

Important: When running the script you will see the Cloud PC status is changing between “Provisioned” “in grace period” and “unknown” in the MEM portal. This is fine. After the script is done, It will eventually go back to “Provisioned”.

Get the latest script at my Github and copy it into your PowerShell editor. The first thing you need to do is provide your Group-based licenses’ group names in the variables. It has to be the correct group you map to the variable. If you map the wrong one, it will resize the Cloud PC to incorrect size, so be sure to get that right.

E.g my license group for my 2vCPU, 8GB RAM, 128GB is called LicensGroup-Windows365Enterprise-2vCPU-8GB-128GB so I map that one to the $W365_2vCPU_8GB_128GB variable. if you don’t have a licensed group for every license, leave them blank.

Now go ahead and run the script.
It will install any module needed. You will need to authenticate and consent to Microsoft Graph if you already haven’t done so. Then you will be prompted to provide a Cloud PC name for the Cloud PC you want to resize.

Next, select the Cloud PC SKU you wish to resize to. I want to resize to 2vCPU, 8GB, 128GB. So I choose number 3.

When confirming the selection by typing “y” the user will be logged out of their Cloud PC without getting notified, and work/data might be lost for that user. So make sure they are aware of you resizing the Cloud PC.

From this point of the script takes care of the rest. Do not do any action to the Cloud PC in the MEM portal, or do not touch license assignment for that user before the script is done. Typically it takes around 10 minutes.

Once the Script is done, we can see the user now got a new size and is part of the correct License group in Azure AD.

Limitations and known issues

  • The script only works with Cloud-only groups used with group-based licensing.
  • Only one resize can be done at a time.
  • The script has some interactive sections, which will currently not work in an automated task.
  • You will have the option to select an SKU size even if you don’t provide a licensed group for that specific SKU size in the variables.
  • The script will not be able to resize a direct assign licensed Cloud PC.
  • The script only works with Windows 365 Enterprise licenses.

Final thoughts

I wish I didn’t have to create my script to simplify resize of group-based licensed Cloud PC. I hope that Microsoft will look into this because it’s a significant need for all customers who is following Microsoft’s best-practice regarding licensing control.

Check out my Github to get the latest script with new features and updates. I’m already thinking about adding support for synched AD groups. You are more than welcome to send any feedback or improvements you might have done yourself. Feel free to reach out to me on Twitter or leave a comment below.

6 thoughts on “Resize group-based licensed Cloud PC with PowerShell

  1. Pingback: Weekly Newsletter – 4th - 10th June 2022 - Windows 365 Community

  2. Gowri K

    can you please explain about this limitation .. what does it mean by Cloud-only groups

    Reply
    1. Morten Pedholt Post author

      Hi Gowri,

      This means it doesn’t work with Group synchronized from Active Directory to the Azure Active Directory.
      It only works with groups created in the Azure Active Directory.

      Reply
      1. Jared Foley

        I’m getting errors that there are no licenses available when I have verified they are there. Did something change that needs to be updated in your script?

        Reply
  3. Niles

    “Unable to find License Windows 365 Enterprise 4 vCPU, 16 GB, 128 GB in Azure AD. Please check if you have the license available
    Ending Script”

    Confirmed that I do have the license in question. Please advise.

    Reply
  4. Jared

    Have you found a way to add a for each loop? I am looking to resize 200 cloud pc’s and this could make my life a lot easier.

    Reply

Leave a Reply

Your email address will not be published.