PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
New-HvPool and Get-HvPoolSpec break on full clones built from running VMs
We make our full clone desktops from running VMs which are always fully patched. This ensures any new machines are fully patched upon first boot.
ParentVM and SnapshotId of New-HVPool are for instant and linked clones only so I can't use these to build my Full Clone pool:
.PARAMETER ParentVM
Parent Virtual Machine to clone Virtual machines.
Applicable only to Linked Clone and Instant Clone pools.
.PARAMETER SnapshotVM
Base image VM for Linked Clone pool and current Image for Instant Clone Pool.
When attempting to get a spec of pool using a running VM as a template the following error produces:
PS C:\Users\myuser> Get-HVPool TESTPOOL01 | Get-HVPoolSpec
Exception calling "VmTemplate_List" with "1" argument(s): "There is an error in the XML document."
At C:\Program Files\WindowsPowerShell\Modules\VMware.HV.Helper\VMware.HV.Helper.psm1:7993 char:10
+ $info = $services.VmTemplate.VmTemplate_List($VcId) | Where- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
The command completes and the json of the pool I attempt to get looks like so for pool:
"VirtualCenterProvisioningData": {
"template": null,
"parentVm": null,
"snapshot": null,
...
},
When I attempt to create a pool using a running VM as my template (this is exactly how it is presented in the gui), I receive the following error:
PS C:\Users\myuser> New-HVPool -spec $specfile
New-HVPool : Failed to create Pool with error: No template VM found with Name: [POWERSHELLPOOL01]
At line:1 char:5
+ New-HVPool -spec $specfile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-HVPool
The json for my spec file is set as so:
"VirtualCenterProvisioningData": {
"template": "POWERSHELLPOOL01",
"parentVm": null,
"snapshot": null,
...
},
In the module, I experimented by switching $templateList to $global:templateList to see what is returned and it is indeed only proper templates from the cluster.