Jump to content


KenG

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by KenG

  1. Hi guys, Last night, I was rebuilding my labs and figured out that we could improve the script to be fully automated. As I'm using differencing disks, I wanted to add support for that. If you would like to know more about differencing disks and how to use them, please reach out and I will be happy to help! Let's start with some variables that I added and/or modified to get this thing started. With the $scriptPath variable, I let the script know in which folder it is located. That make things easy to import my csv file. $scriptPath = split-path -parent $MyInvocation.MyCommand.Path $Names = Import-csv $scriptPath\ServerNames.csv The $ParentDisk variable is a hardcoded link to the Parent Disk used for differencing. $ParentDisk = "G:\Keduco\BaseDisk\W2K16_Parent.vhdx" The variables below are changed from Read-Host to a hardcoded value. TIP: It would be even more clean to put the variables below in the csv file as well. 😉 $SwitchName = "Keduco - VLAN1 - 192.168.1.x" $Generation = "2" Now that we have set all our variables, it's time to import the csv file and fill the variable $Name Once our $Name variable is set, we need to focus on the real job... Creating our VMs. That's where I changed things a little bit. I reversed the check dir to store the VM procedure, this because it breaks if the folder allready exist. If we check if the folder is missing, it will first create the Folder and the VM. Does the folder exist, it will just skip and continue with the rest of the VMs. So you can easely add or remove VMs from your csv input file, you can re-run the script as many times as you want, cause it will skip what is created and create what is added to your csv file. I'm sure that you can still improve the script a lot, I mean using a csv to create different types of VMs based on different switches, different generations etc... I created a zip file with the modified script and csv file. Feel free to reach out for help if needed! Best Regards, Ken CreateVMs.zip
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.