A skála egy számítógép réteg (parancsfájl)
Érvényes: System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager
Alatt a szolgáltatás méretezés telepített szolgáltatás által használt erőforrások mennyisége csökkenthető. A szolgáltatás átméretezéséhez egy virtuális gép eltávolítása a számítógép rétege, vagy módosítsa a virtuális gép állapotát. Meghatározza, hogy a számítógép számítógépréteg bővíthető-e a beállításával a InstanceMinimumCount a számítógépréteg-sablon paraméternek.
A jelen témakörben található a parancsprogram két paraméter-készlet tartalmazza. Mindkét paraméter készletek megadását a szolgáltatás és a számítógép szint. Azonban itt adhatja meg, hogy a virtuális gép használatával eltávolítani a RemoveVM Váltás, vagy a virtuális gépen egy művelet használatával végezze el a VMAction paraméter.
A következő parancsfájl ellenőrzi, hogy tudunk biztosításával, hogy egy virtuális gép eltávolítása a szolgáltatás nem okoz Ugrás a minimális számítógépszámnak a szinthez alatt a szolgáltatás egy szinten lévő réteget. A parancsfájl majd megkeresi a a legutóbb létrehozott virtuális gépet, hogy fut-e a számítógép rétege és vagy eltávolítja a virtuális gépet, vagy nem fut államok eldöntésére helyezi a virtuális gép.
# Description: The script verifies that you are able to scale in a tier and, if so,
# the script locates the most recently created virtual machine running
# on the computer tier and either removes the virtual machine or stops,
# pauses, stores, or saves the state of the virtual machine.
Param (
[parameter(Mandatory=$true,ParameterSetName="RemoveVM")]
[Switch]
$RemoveVM,
[parameter(Mandatory=$true,ParameterSetName="RetainVM")]
[ValidateSet("Stop","Pause","SaveState","Store")]
[String[]]
$VMAction,
[parameter(Mandatory=$true)]
[String]
$Service=$(throw "Please provide the name of a service."),
[parameter(Mandatory=$true)]
[String]
$ComputerTier=$(throw "Please provide the name of a computer tier."),
[parameter(Mandatory=$false,ParameterSetName="RetainVM")]
[String]
$LibraryServer,
[parameter(Mandatory=$false,ParameterSetName="RetainVM")]
[String]
$LibraryPath
)
# Get the service and the computer tier.
$ServiceInstance = Get-SCService -Name $Service
$Tier = Get-SCComputerTier -Service $ServiceInstance | where {$_.Name -eq $ComputerTier}
# Ensure that you are able to scale the tier in.
If ($Tier.VMs.count -le $Tier.InstanceMinimumCount) {throw "You have reached the instance minimum for this tier."}
# Find the most recently created virtual machine in the tier that is running.
$VMs = @(Get-SCVirtualMachine | where {$_.ComputerTier -eq $Tier -and $_.Status -eq "Running"}) | sort -Property CreationTime -Descending
$VM = $VMs[0]
If ($RemoveVM)
{
Stop-SCVirtualMachine -VM $VM -Force
Remove-SCVirtualMachine -VM $VM
}
Else
{
If ($VMAction -eq "Stop")
{
Stop-SCVirtualMachine -VM $VM
}
ElseIf ($VMAction -eq "Pause")
{
Suspend-SCVirtualMachine -VM $VM
}
ElseIf ($VMAction -eq "SaveState")
{
Stop-SCVirtualMachine -VM $VM -SaveState
}
ElseIf ($VMAction -eq "Store")
{
Save-SCVirtualMachine -VM $VM -LibraryServer $LibraryServer -SharePath $LibraryPath
}
Else
{
throw "You did not provide a valid action for the virtual machine."
}
}