The Get-FolderByPath function was updated yesterday, so you better get the new version.
Although I don't think this has any effect on your script.
I would use the parameter -IpMode:UseStaticIP as -IpMode UseStaticIP .
Not sure if it works correctly the way you did it.
The OSCustomization is applied at the first start of the VM, so I'm not sure if removing it before you start the VM could be causing any issues.
The log it leaves behind could perhaps give some pointers on what might be going wrong.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Understood; I'll grab your latest function. Nice work on that one by the way...
Interesting points regarding the start of the VM in relationship to the deletion of the temporary custom spec; I had not considered that. (Side note: I wish the -Type NonPersistent switch worked with New-OSCustomizationSpec...) I'll make the changes and report back.
Still no joy...
By the way, the -IpMode:UseStaticIP works - as is - in two other script I have. One deploys VMs by cloning another powered-off VM and the other deploys them via a template. Both prompt the user to enter IP info as the script progresses. Both scripts were the precursors to the one I'm working on now... Anyway, I made your recommended change to -IpMode UseStaticIP but that didn't make a difference.
I constantly watch the output while the scripts run - just to catch any errors. I managed to capture the output and, again, it all looks like it's creating a VM with all the correct info. Before my original post, I even filled the CSV with some bogus data - trying to trick the script into a failure - thinking the script just wasn't pulling in the correct data. However, that didn't seem to make a difference; it seems the data is being pulled in correctly.
Looking at that KB article let nowhere. None of the paths seem to apply to my Windows 2012 server. I poked around the %Windir%\Temp directory but anything looking to be VMware-related, was empty.
I also commented out the Remove-OSCustomizationSpec bit to test the deletion and powering-on theory. Again, there was no change in the final product.
Also note that the Remove-OSCustomizationSpec in the other two scripts is done before the Start-VM - again, with successful results. So, I'm not sure changing that order makes much of a difference. At least not in my case...
If %Windir%\Temp is empty, that seems to indicate that the OS Customization didn't run at all.
Is there anything in the vmware.log (in the VM's folder) that could help ?Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Well, that's a busy log.... 2300 lines up on Pastebin for everyone's viewing pleasure. It was located inside the VM's folder on the cluster's storage. I see a lot of Remote connection failure messages at the bottom of said file.
Found my issue. Everything was fine except for the New-VM line; it had the wrong variable for the -OSCustomizationSpec switch. Feeling a bit foolish but it's been a long week.
New-VM -Name $GuestVM -Template $Template -Location $VMFolder -OSCustomizationSpec $CustSpec -ResourcePool $Cluster -Datastore $Datastore
New-VM -Name $GuestVM -Template $Template -Location $VMFolder -OSCustomizationSpec $TempCustSpec -ResourcePool $Cluster -Datastore $Datastore
First of all, thanks for this and Sorry for waking up an old thread.
Can I ask why run "Remove-OSCustomizationSpec $GuestVM -Confirm:$False"?
I missed the point there.
The user creates a persistent OSCustomizatonSpec, and he cleans it up after he's done with it.
He could have created a nonpersistent one, that would have been removed automatically when the PS session was closed.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Thank you very much for this script, it works as it should. I have customized it a little bit adding value for memory and CPU/Core values. There is one thing that we use very often during deploying VM from templates, which is adding additional hard drive disks that are located on same DS as deployed VM. Disks are always added in Thick - Lazy Zeroed format.
Would it be possible to add value in CSV like DiskNum and DiskSize that would automatically add vdisks to VM after deploying from template?
Let's say DiskNum - value 3, DiskSize 5-10-15 (add three disks with size 5GB, 10GB and 15GB)?
If that's possible, could you just give me the idea how to even start it? Should I use -DiskGB during New VM creation?