Thursday, January 7, 2016

VMware vmFork Script

You can take vmFork for a test spin utilizing the latest PowerCLI Extension fling. Below is a script I put together for demonstrating Instant Clone within your own lab. It's based on these two VMware blog posts:

https://blogs.vmware.com/PowerCLI/2015/08/vmware-instant-clone-now-fingertips-new-powercli-extensions-fling.html

http://blogs.vmware.com/PowerCLI/2015/08/using-vmware-instant-clone-via-powercli-extensions-fling.html

If you're interested in more details, I'd definitely start with these two posts above. Otherwise, if you want to get up and running very quickly with an instant clone demo, follow these steps below. Not only will running this script create instant clones, but it will also give each clone a unique IP address. Further, when your done it can tear down the demo for you by deleting your clones and shutting down the parent VM. Here are the steps:


1. Create a Windows 2012R2 VM.

2. Install latest release of PowerCLI available here.

3. Download the latest PowerCLI extensions from here.

4. If necessary, flag your zip file as unblocked before continuing. (You may experience security issues later that are harder to correct.)

5. Unzip the PowerCLI Extensions to preferably c:\program files (x86)\VMware\VMware Infrastructure\vSphere PowerCLI\Modules or an appropriate path.


6. Create a file named post-clone.bat and add the following lines codes displayed:


7. Create a powershell script by any name you like and add the lines of code showed at the bottom of this page. Ensure it's in the same directory as post-clone.bat

8. At the top of the file there's a section where you populate the script with information about your environment and how you want to child VMs created.


9. Run PowerCLI as an administrator.

10. Set your execution policy "Set-ExecutionPolicy RemoteSigned"

11. Execute your script and make it rain VMs!!!!!!!


Here's what it looks like in vCenter:


You can clean up this environment by pressing any key at the PowerShell prompt. It will go on to delete all your child VMs and shutdown the parent VM.

The Script Itself: