This is a follow-up to my last post about fully automated deployment

Below is the script. After it pulls the information from you, it creates the VM, adds the second disk, sleeps for 15 seconds, pulls the MAC from the new VM, creates the computer object in SCCM, adds it to the collection, sleeps for 15 seconds, refreshes the collection, sleeps for 15 seconds, then powers on the VM. If you’ve got a mandatory OSD advertised to the collection specified, and the OSD is fully automated, it will lay down the OS and the computername will be the name you provided to the script.

There are some variables you will have to set to make it work for you. Our standard is to have two disks per VM, one for the OS, one for data. I have the OS disk hard coded to 64GB, and the script prompts you for the data disk. The OSID labels for the guest OS were taken from the API reference guide.

The SCCM portion was adapted from Antoine Habert, in combination with the /\/\o\/\/ WMI Browser.

This script also thin provisions both disks. This can be changed in the createvm function. Also, you will need PowerShell v2 and PowerCLI 4.1.1 to run this script.

**UPDATE 06/07/2011**
I added one function to actually launch the remote console (vmware-vmrc.exe). I hard-coded the path (line 222). I have both 4.0 & 4.1 installed, but used 4.0 for no particular reason, and also set the user & pass as variables, or delete the -u & -p from line 222 if you want to manually specify a user/pass each time. This user will need to reside on the host specifically (I have a script that creates the Role, as well as the user, for this). You could comment out the function call itself if you don’t want it (line 252). I know the pw is there in clear text, but if created properly, it can only view the console.