次の方法で共有


Deploying multiple VM's from a VM Template in SCVMM

Without an option in the New VM Creation wizard, to specify how many VMs you want to create, the only alternative you have is to use PowerShell.

I do not claim to be an expert at PowerShell, so if you are new to PowerShell and VMM here is a quick beginner script that might help you to deploy multiple VMs:

The following script, will prompt you to enter the number of VMs you want to deploy, the VM template you wish to deploy from, the "Base Name" you enter will be used for all VMs deployed, however it will appear with a number increment, to ensure all VMs have a unique name, you are asked to specify the host in which to deploy to and lastly enter the file path where you want the VM to be stored, the example given is for Volume1 on a CSV.

#Beginning - Copy and paste this into a notepad/PowerShell script compiler and save as a .ps1 file

[int]$VMcount = Read-host “Input Number of VMs”
$VMTemplate = Read-host "Input VMTemplate Name"
$VMName = Read-host “Input Base Name”
$VMHost = Read-host "Input Host Name"
$VMPath = Read-host "Input VM Path (example: C:\Clusterstorage\Volume1)"

$Total = 1

While ($total -le $VMCount) {$NewVMName = “$VMName-” + $total

Write-Output $virtualMachineConfiguration

New-SCVirtualMachine -Name $NewVMName -VMHost "$VMHost" -path "$VMPath" -VMTemplate "$VMTemplate" -ReturnImmediately -DelayStartSeconds “0"

$Total++

}

#End

I will be following up this article with further "beginner" style PowerShell script examples, that I found useful when getting to grips with VMM. I hope you find this and them useful...