Scripting Virtual Server with PowerShell - Create-ChildVM.ps1


I hate writing up scripts. Writing the scripts themselves is great, it’s just explaining them after which is really boring J


Here is the second demo script I used last week, Create-ChildVM.ps1. This script is invaluable if you need to quickly deploy machines in a test lab. I say test lab rather than production because this script uses differencing disks, which do not perform as well as fixed disk. They are great to use when you have disk space constraints, but on a beefy production system I would use fixed disks. A differencing disk has a read-only parent disk which can be used to store the operating system. Then any changes made to the disk are actually stored in the differencing disk. In this example my parent disk is a Windows 2003 SP2 sysprepped disk. The child then holds any differences. Multiple children can point to the same parent and parent disks can be chained together.


This script takes no parameters, and provides a menu system. The VM is created in seconds and the machine is up running in a matter of minutes.

I won’t explain the whole script, but just shout if you have any questions. There is no error checking in this script. Version 2 will have some error checking built in – I promise J

Thanks go to Steven Adler who's code I plagiarised for some (most) of the sections.