You dont have javascript enabled! Please enable it!

How to Associate a Cloud to Multiple Virtual Machines in VMM with PowerShell #SCVMM #PowerShell

2 Min. Read


Hello folks,

As you know that in System Center Virtual Machine 2012 R2, we can create “Clouds” as pools of delegated resources that abstract the underlying physical fabric such as compute, network and storage. We can create multiple Clouds for varying business units needs or tenants, and then present each Cloud with a defined capacity that we can increase later, decrease or customize as needed. In this manner, Virtual Machine Manager provides us with a lot of flexibility for mapping our data center capacity to changing business requirements while not exposing the full fabric capacity details to customers.


In SCVMM in order to deploy a service to a cloud, you must have the following requirements in place:

Service Templates that are configured through the use of many VMM resources such as virtual hard disks, VM Templates, Guest OS profiles, Hardware profiles, and other VMM library resources. The service template allows us to configure how many Virtual Machines are initially deployed as part of the service deployment, then configure the applications to be installed at deployment time.

For example, when you deploy a multi-tier application to a tenant or business unit, the virtual machines that belong to this service will be associated with a Cloud.

The following figure will illustrate the picture:


The first question is what if you already have a virtual machine that was manually deployed without Service Template, would you be able to associate it to a Cloud?

The answer is YES! Smile

How to do it?

You can browse to the VM and follow the steps below:

VM not associated with a cloud


VM associated with a cloud


The second question is what if you have 100 virtual machines that were manually deployed without Service Template, would you still be able to associate them to a Cloud?

The answer is YES!

How to do it?

Well, same as we did above… very simple.

Really, NOOOO!

So I have created the following simple PowerShell tool that will save you 400 clicks on your mouse, 4 clicks per VM.

Set the Associate Cloud to Multiple Virtual Machines.

This script will set or remove cloud association for all Virtual Machines to a specific Tenant and Host Group.

File Name : Set-AssociateCloud.ps1
Author    : Charbel Nemnom
Version   : 2.0
Requires  : PowerShell Version 3.0 or above
OS        : Windows Server 2016 or above with System Center Virtual Machine Manager 2016 and 2019

To provide feedback or for further assistance please visit:

./Set-AssociateCloud -TenantCloudName <CloudProvider> -HostGroupName <Hosts>
This example will set the cloud association to all virtual machines for a specific Tenant and Host Group.
./Set-AssociateCloud -TenantCloudName <CloudProvider> -HostGroupName <Hosts> -AssociateCloud No
This example will remove the cloud association from all virtual machines for a specific Tenant and Host Group.




$Cloud = Get-SCCloud -VMMServer localhost | where {$_.Name -eq $TenantCloudName}
$hostGroups = Get-SCVMHostGroup -Name $HostGroupName
Foreach ($hostGroup in $hostGroups.AllChildHosts) {
    $VMs = Get-SCVirtualMachine -VMMServer localhost -VMHost $HostGroup
    foreach ($VM in $VMs) {
        If($AssociateCloud -eq 'Yes') {
        Set-SCVirtualMachine -VM $VM.Name -Cloud $Cloud
        Else {
        Set-SCVirtualMachine -VM $VM.Name -RemoveFromCloud

If you need to associate all virtual machines to a specific tenant and host group, you can run the following cmdlet:



The default parameter to Associate Cloud is Yes, if you want to dissociate a Cloud from all Virtual Machines, then you need to add the parameter –AssociateCloud No



Hope this helps!

Until then… see you in the Cloud Smile


Photo of author
About the Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect, Swiss Certified ICT Security Expert, Certified Cloud Security Professional (CCSP), Certified Information Security Manager (CISM), Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT). He has over 20 years of broad IT experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems with extensive practical knowledge of complex systems build, network design, business continuity, and cloud security.

Related Posts


StarWind Free Webinars, Protecting Virtual Machines, Building Hyper-V Cluster and Building Scale-Out File Server Without JBODs #HyperV #StarWind

Free New Webinar & eBook: Microsoft Licensing for Hyper-V #Altaro #HyperV


Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the \'Code Blocks\' in \'Black\' by selecting the Code. Thank You!