How to Associate a Cloud to Multiple Virtual Machines in VMM 2012 R2 Via PowerShell #VMM #SysCtr #SCVMM #PowerShell

4 min read

Hello folks,

As you know that in System Center Virtual Machine 2012 R2, we can create “Clouds” SmallCloud 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 provide us with a lot of flexibility for mapping our datacenter 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 to a Cloud.

The following figure will illustrate the picture:


The first question is what if you already have 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 to a cloud:


VM associated to a cloud:


The second question is what if you have 100 virtual machines that was 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 Surprised smile NOOOO!

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

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    : 1.0
Requires  : PowerShell Version 3.0 or above
OS           : Windows Server 2012 or above with System Center Virtual Machine Manager 2012 R2

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
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


About Charbel Nemnom 578 Articles
Charbel Nemnom is a Cloud Architect, Swiss Certified ICT Security Expert, Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems. Excellent communicator is adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design, business continuity, and cloud security.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.