I am trying to create a PowerCLI script that will create VM's based on settings that are taken from a CSV file. The CSV file is a result of a VBA script extracting data from an Excel spreadsheet that users will have entered their desired settings. What I have so far:
$CSVPath = "C:\NewVMList.csv"
$CSVFILE = Import-CSV $CSVPath
$VMhost = Get-vmhost "$($CSVFile.VMHost)"
$PortGroup = Get-VirtualPortgroup -name "$($CSVFile.VLAN)" -VMhost $VMhost
New-VM -Name "$($CSVFile.Name)" -MemoryGB "$($CSVFile.MemoryGB)" -NumCPU "$($CSVFile.NumCPU)" -portgroup $Portgroup -DiskGB "$($CSVFile.C_System)"
The CSV file that it will be referencing for the values will have 3 cells that are available for the various partitions to be assigned space (C:\, D:\, M:(app data)).
What I would like to know is if there is a function that I can use within my PowerCLI script that can assign the various partitions the appropriate amount of space based on the CSV file or if this would need to be done manually?
Would it require something other than the -DiskGB "$($CSVFile.C_System)"
to create partitions, as this seems to reference the overall disk space being allocated (I am probably wrong, please feel free to correct me)?
Partitioning is handled via the Windows OS rather than VMware so you would need to have some sort of post-build task taking over(if you'd like help with that you can create a chat with me, happy to help but theres a bunch of other variables we'd have to discuss)
However the easy and probably better way to accomplish this is to just add 3 separate hard disks to the server. They are all just VMDK files sitting on a SAN so having 3 disks with 1 partition each is not really much different than having 1 disk with 3 partitions, except you can declare all three disks at VM creation. so you'd do your New-VM
with a harddisk size matching the requested size of C:\, then add 2 additional disks using New-HardDisk
. This has the added benefit of making it MUCH easier to later extend the C:\ and D:\ drives, and makes your storage more flexible if you ever start having to move VMDK's around for performance or capacity reasons.