In this post we are going to look on another alternative way to create virtual machine. The tool that we are going to use is Microsoft Powershell Deployment Toolkit (PDT). We have modified the default PDT variable to just use it for
- Provisioning a virtual machine with different configuration
- Assign IP Address
- Join to Domain
This come handy when you just would like to provisioning several virtual machine without install any roles/application and then pass Application team for application deployment.
Pre-requisite:-
a) Windows Server 2012 R2 Hyper-V
b) Downloaded PDT from Technet Gallery:- Click here
c) Base image either Windows Server 2008 R2, Windows Server 2012 or Windows Server 2012 R2. You can refer to our previous post on how to create
Note:- Just create a virtual machine, do not run downloader.ps1 and installer.ps1. In this exercise, we are “NOT” setting up System Center deployment.
Default:-
- VM Location = C:\VMs
- Virtual Processor = 2
- Computer name start with prefix = MS4U
- Dynamic memory =
Startup –1024MB
Min – 512MB
Max – 2048MB
Buffer 20%
- Virtual Switch = External
- Assign static IP starting from 192.168.168.70
- Gateway = 192.168.168.254
- DNS = 192.168.168.201
- Automatic start = nothing
- Delay = 0
- Automatic stop = Save
- DVD = None
- Additional 1 data disk =Yes
VM Name | Processor | Memory | Data Disk |
TestVM1 | default | default | default |
TestVM2 | default | Startup –1024MB Min – 512MB Max – 8192MB Buffer 5% | Create 3 additional disk with each 50GB size |
TestVM3 | default | Startup –2048MB Min – 2048MB Max – 2048MB Buffer 20% | default |
TestVM4 | default | default | default |
Modify the default variable.xml or just create a new variable.xml with just below information. Example:- Create 4 Windows Server 2012 R2 Virtual Machine
<?xml version="1.0" encoding="utf-8"?> <VMs> |
Output when execute VMCreator.ps1:-
Above script will create:-
- Generation 1 VM. To modify to generation 2 VM, on the default section, do add
<VMGeneration>2</VMGeneration>
- If your base image is dynamic disk, then the target VM will be dynamic disk as well. By default, the script is using differencing disk.
<Parent>C:\VHD\WS12R2D.vhdx</Parent>
<Type>Copy</Type>
- The <Count>4</Count> must match to the end value of VM Count :-
<VM Count="4">
Please feel free to modify the script according to your environment.