Export (0) Print
Expand All

Scale Out a Computer Tier (Script)

Updated: November 1, 2013

Applies To: System Center 2012 - Virtual Machine Manager, System Center 2012 R2 Virtual Machine Manager

After you have deployed a service in VMM, you can scale out a service by adding a virtual machine to a computer tier. You define whether a computer tier can be scaled out by setting the InstanceMaximumCount parameter for a computer tier template.


The following script checks whether you are able to scale out a tier by ensuring that adding a virtual machine will not exceed the maximum machine count for the tier. The script then scales out the service by adding a virtual machine to a computer tier.

# Description:      This script scales out a service by adding a virtual machine
#                   to a computer tier.

# Get the service and the computer tier.
$Service = Get-SCService -Name "Service01"
$Tier = Get-SCComputerTier -Service $Service | where {$_.Name -eq "Web Tier"}

# Ensure that you are able to scale out the tier.
If ($Tier.VMs.count -eq $Tier.InstanceMaximumCount) {throw "You have reached the instance maximum for this tier."}

# Create a virtual machine configuration for the computer tier.
$VMConfig = New-SCVMConfiguration -ComputerTier $Tier -Name "NewServiceVM01" -Description "New virtual machine configuration for tier"

# Get the best host on which to deploy the virtual machine.
$VMHosts = Get-SCVMHost
$HostRatings = @(Get-SCVMHostRating -VMHost $VMHosts -VMConfiguration $VMConfig | where {$_.Rating -gt 0} | sort -Property Rating -Descending)
If ($HostRating.Count -eq 0) {throw "No hosts meet the placement requirements."}
$VMHost = $HostRatings[0].vmhost

# Set the host on the virtual machine configuration.
Set-SCVMConfiguration -VMConfiguration $VMConfig -VMHost $VMHost
Update-SCVMConfiguration -VMConfiguration $VMConfig

# Create a virtual machine for the service.
$VM = New-SCVirtualMachine -Name "NewServiceVM01" -VMConfigurationScaleOut $VMConfig

See Also

For additional resources, see Information and Support for System Center 2012.

Tip: Use this query to find online documentation in the TechNet Library for System Center 2012. For instructions and examples, see Search the System Center 2012 Documentation Library.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft