Associate SCVMM virtual machines to Cloud

So you may have dozens or more VMs to be associated with a VMM cloud. Instead of clicking 4 times/VM, here’s a script to do it for you.

This one does it per cluster. You can modify the filter to do it for all machines in your environment or those on certain hosts, upto you.


$Cloud = Get-SCCloud -Name <insert name of cloud you want VMs to be associated with>

$Cluster = Read-Host -Prompt 'Enter cluster FQDN'

Write-host ""
Write-host ""

$VMsInYourClusterNotInCloud = Get-SCVirtualMachine | Where {$_.vmhost.hostcluster.name -eq $Cluster -and $_.Cloud -eq $null}

foreach ($VM in $VMsInYourClusterNotInCloud)
{Set-SCVirtualMachine -VM $VM -Cloud $Cloud -RunAsynchronously | Out-Null
Write-Host {"$VM has been made part of the $Cloud cloud" -ForegroundColor Cyan}

2 Comments

 Add your comment
  1. I am facing the error while I am running the script . I am mentioning all the right details on the script but some error is showing related to cluster FQDN , I mentioned the correct cluster FQDN . Can you please help me ?

Leave a Comment

Your email address will not be published.