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

2 Min. Read

Hello folks,

As you know that in System Center Virtual Machine 2012 R2, we can create “Clouds” SmallCloudas 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



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

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

Subscribe to Stay in Touch

Never miss out on your favorite posts and our latest announcements!

The content of this website is copyrighted from being plagiarized!

You can copy from the 'Code Blocks' in 'Black' by selecting the Code.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!