General vCenter

Automating Sysprep File Transfer to vCenter

I was at my local Salt Lake City VMware User Group (VMUG) last week doing a Q&A when one of the users mentioned it is painful to only be able to upload one Sysprep file at a time to vCenter. I wanted to take the time to address this for him as well as any of you who may have the same issue.

Problem: uploading Sysprep files to vCenter only allows for one file upload at a time.

Currently to upload a Sysprep file, one must login to to the VCSA web interface click on “Summary”, then “Upload” (bottom right).

Screenshot2014062719.57.49.png

You then select the desired target directory and choose the Sysprep files one at a time.

Screenshot2014062720.06.02_thumb.png

 

For the Windows vCenter Server the files must be placed within their respective folders within C:\ProgramData\VMware\VMware VirtualCenter\Sysprep\.

image.png

This is not always the easiest process to add several Sysprep files to vCenter. So I decided to create a script that will do it for me.

The Script

Once you download the script (see the end of the blogpost for the download link), open it up and read through the script to become familiar with what it does. As always, never run a script in your environment unless you know exactly what it is doing and you are comfortable with it.

After the script comments you’ll see there is a block of variables that need to be set according to your environment. The $DefaultVIServer along with $vCUser and $vCPass are the credentials for the script to login to the vCenter where your target vCenter resides (*Note: These can be one and the same, however, in larger environments some users have multiple vCenters). The $target variables are for the vCenter we will be loading the Sysprep files to.

For the script to work correctly you’ll need to create a folder and create the folder names as you see them in the picture above. All of the Sysprep files should be places respectively in their folders. The $Location variable is the location where these subfolders reside on your local machine; for me it was C:\Temp.

If the Sysprep files will be uploaded to a Windows vCenter Server and vCenter is not installed on the C: partition, the $vC_partition variable will need to be updated to the correct drive.

image.png

Once the files have been placed in their folders and the User Configuration has been set, the script is ready to run.

The script will check to see if vCenter is the VCSA or a Windows VM and will place the files accordingly. This script will not overwrite any files in the Sysprep repository by default. If you plan on having this script overwrite files with the same filename you must add ‘-Force’ to the end of the Copy-vmguestfile command at the bottom of the script.

You can grab the script HERE