Home > Virtualization > Rapid Provisioning in VMM 2008 R2 using the UseLocalVirtualHardDisks and SkipInstallVirtualizationGuestServices flags

Rapid Provisioning in VMM 2008 R2 using the UseLocalVirtualHardDisks and SkipInstallVirtualizationGuestServices flags

 
Here is a sample script where a new virtual machine is created by utilizing the local VHD d:file.vhd without copying any VHDs over the network.

<<

#specify the file location
$VHDName = "d:file.vhd"

#specify other variables for new-vm
$vmname = "vm1"
$hostname = "host.contoso.com"
$vmhost = get-vmhost $hostname

#create jobgroup ID for new-vm from template
$VMGuid = [System.Guid]::NewGuid().ToString()

#specify the local location for the VHD

#VMM expects that $VHDName already exists on the host computer when the new-vm cmdlet is called.
Move-VirtualHardDisk -Bus 0 -LUN 0 -IDE -Path $VHDName -JobGroup $VMGuid

#get the template name
$template = Get-Template | where {$_.Name -eq "template_2"}

#Get the current username to be passed as the VM owner
$callerUsername = whoami

#create the new-vm from template and specify the Rapid Provisioning flag (-uselocalvirtualharddisks)
New-VM -Template $template -Name $vmname -Description "" -Owner $callerUsername  -VMHost $vmhost -UseLocalVirtualHardDisks -Path $vmhost.VMPaths[0] -RunAsynchronously -JobGroup $VMGuid | Out-Null
 >>

Thanks to Michael Michael from http://blogs.technet.com/m2/

 

Categories: Virtualization
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: