8 Replies Latest reply on May 17, 2018 12:25 PM by JohnnyStep

    Creating a VM from template doesn't use template settings/disks

    JohnnyStep Lurker

      I am trying to use PowerCLI to deploy multiple VMs from a template in vSphere 6.0.0, and when I attempt to do this, the machine that is created does not appear to use the template at all. The template contains two hard disks (80 GB and 120 GB), 16 GB of memory, and 8 vCPUs. As shown below, the new VMs are created with a single 4 GB disk, 256 MB of memory, and 1 vCPU. I have tried running the command a number of different ways, with different options specified on the command line, and with or without variables or actual names specified for resourcepool, template, etc. Nothing seems to work. Of course, if I deploy from this same template in the vSphere client, it works fine. What am I missing here?

      PowerCLI C:\> new-vm -name test01 -resourcepool $cluster -template $template -confirm

      Confirmation
      Proceed with creation of a virtual machine with the following parameters:
      Name: test01
      DiskMB: 4096
      MemoryMB: 256MB
      NumCPU: 1

        • 1. Re: Creating a VM from template doesn't use template settings/disks
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          And your sure the template is what you think it is?

          Convert it back to a VM and then do a Get-VM to make sure.

          • 2. Re: Creating a VM from template doesn't use template settings/disks
            JohnnyStep Lurker
            Yes, I'm positive. I even tried creating a new template from a VM to eliminate this as a possibility, and I still got the same result.
            • 3. Re: Creating a VM from template doesn't use template settings/disks
              LucD Guru
              User ModeratorsvExpertCommunity Warriors

              A few things to check:

              • the $template variable contains a single object, and that is indeed the template from which you want to create a VM
              • is the template created on the same ESXi node where you are now trying to create the VM?
                • Are the requested resources available on that ESXi node
              • Anything in the Task & Events for the creation of the VM?
              • Did you add the -Verbose switch on the New-VM
              • Can you try adding the Datastore parameter on the New-VM, so to direct the new VM to a specific datastore
              • Anything in the vpxd log?
              • Does the same happen when you create a VM from that template via the Web Client?
              • 4. Re: Creating a VM from template doesn't use template settings/disks
                JohnnyStep Lurker

                LucD,


                Yes, the $template variable only contains a single object, and is the correct template that I am trying to use.


                I originally was specifying the cluster instead of an ESXi host for the ResourcePool parameter, but I tried it with the same ESXi host that the template is on, and I had the same result.


                The -verbose switch isn't returning anything additional that is helpful.


                I was specifying the Datastore parameter for most of the command lines that I tried, and it has plenty of free space.


                Creating a VM from the same template was successful in the Web Client, and disks, memory, and vCPUs were provisioned as expected, just as in the thick client.

                 

                 

                So, I did find the issue. You had asked what was in Tasks and Events, and my command line had included the -confirm switch, so I was aborting before attempting creation due to the fact that it was telling me it was going to create a VM with the wrong specs. When I ran the command without the -confirm switch, everything worked fine!! The VM was created with the right number of vCPUs, disks with the right capacity, and the right amount of memory. I then re-ran the same command (new VM name) and included the -confirm switch. It again told me it was only going to use a 4GB disk, 256 MB of memory, and 1 vCPU, but it still created a VM as per the template with the right specs. I then switched back to specifying a host cluster instead of an individual host, and again had success. I know for certain that the first several times I tried this yesterday, I did actually have a VM created with only 1 4GB disk, 256 MB of memory, and 1 vCPU. I will have to back track to see which command line change actually created a bad VM, but it definitely seems that the -confirm switch is lying to me.


                Thank you for your help today! Having this working is really going to save a ton of time for us going forward.

                • 5. Re: Creating a VM from template doesn't use template settings/disks
                  LucD Guru
                  User ModeratorsvExpertCommunity Warriors

                  I can confirm (lol) that the Confirm message gives incorrect info.

                   

                  Tested with a template with 2 vCPU, 1GB of memory and a 20GB harddisk.

                  And the Confirm message showed me:

                  confirm.jpg

                   

                  The VM was created correctly, but the message might confuse users.

                  • 6. Re: Creating a VM from template doesn't use template settings/disks
                    JohnnyStep Lurker

                    "Confirm". Hah!

                    Yes, this message is certainly confusing. It caused a lot of wasted time the other day while trying to deploy machines. I am certain that one of the machines that I went ahead and deployed did, in fact, have the bad specs reported by the confirmation message, but I'm not sure what the difference was in the command line that accounted for the differing results. Can you point me the in the right direction to report this as a bug?

                     

                    Thanks again for your help!

                    • 7. Re: Creating a VM from template doesn't use template settings/disks
                      LucD Guru
                      User ModeratorsCommunity WarriorsvExpert

                      You can create a SR.

                      If the support people claim PowerCLI requires a special Developer Support contract, refer them to PowerCLI Support Breakdown.
                      For obvious bugs in the cmdlets, not in your scripts, a regular Support Contract is sufficient.

                       

                      I already reported the issue to the PowerCLI PM, but it won't hurt if more people report it.

                      • 8. Re: Creating a VM from template doesn't use template settings/disks
                        JohnnyStep Lurker

                        I'm actually a Citrix guy, not on the server team, so I don't have access to create an SR. I feel better knowing that you reported it up to the PM, though. I just wanted to make sure that it got on someone's radar.

                         

                        Thanks again!