VMware Cloud Community
chrismanuele
Contributor
Contributor

Duplicate DataStore preventing New-VM from completing execution

Hello,

I am trying to deploy a new VM from a template but am receiving an error because the DataStore value being used shows up twice, under two different DataCenters. 

PS C:\Windows\system32> New-VM -Name 'CM-NewVM' -Template 'DEPLOY-W19-DB19' -VMHost 'uscavs-esx2.aperio.int' -Datastore 'EQL QA-DEV1'
New-VM : 7/30/2021 3:20:04 PM New-VM The specified parameter 'Datastore' expects a single value, but your name criteria 'EQL QA-DEV1' corresponds to multiple values.
At line:1 char:1
+ New-VM -Name 'CM-NewVM' -Template 'DEPLOY-W19-DB19' -VMHost 'uscavs-e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (System.Collecti...dObjectInterop]:List`1) [New-VM], VimException
+ FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_MoreResultsThanExpected,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

New-VM : 7/30/2021 3:20:04 PM New-VM StorageResource parameter: Could not find any of the objects specified by name.
At line:1 char:1
+ New-VM -Name 'CM-NewVM' -Template 'DEPLOY-W19-DB19' -VMHost 'uscavs-e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (VMware.VimAutom...ource Datastore:RuntimePropertyInfo) [New-VM], ObnRecordProcessingFailedException
+ FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

You can see that there are two DataStore entries when searching by Name:

PS C:\Windows\system32> Get-DataStore -Name 'EQL QA-DEV1'

Name        FreeSpaceGB CapacityGB
----------- ---------   ----------
EQL QA-DEV1 1,016.021   15,359.750
EQL QA-DEV1 1,016.021   15,359.750

I can narrow it down to the one I want by specifying the DataCenter Location:

PS C:\Windows\system32> Get-DataStore -Location 'QA/Dev' -Name 'EQL QA-DEV1'

Name        FreeSpaceGB CapacityGB
----------- ---------   ----------
EQL QA-DEV1 1,016.021   15,359.750

I have tried using that command to send in the DataStore I want as a variable but have not had any luck:

PS C:\Windows\System32> $DataStore = Get-DataStore -Location 'QA/Dev' -Name 'EQL QA-DEV1'
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template 'DEPLOY-W19-DB19' -VMHost 'uscavs-esx2.aperio.int' -Datastore $Datastore
New-VM : 7/30/2021 3:36:56 PM New-VM
At line:1 char:1
+ New-VM -Name 'CM-NewVM' -Template 'DEPLOY-W19-DB19' -VMHost 'uscavs-e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], InvalidProperty
+ FullyQualifiedErrorId : ViCore_Util10_EncryptionServiceHelper_UpdateViewData_ViErrror,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

Seems to be a type mismatch but I've gone through the documentation and can't seem to find a way to convert it to a value it will accept. Thanks in advance for your help.

 

 

0 Kudos
23 Replies
LucD
Leadership
Leadership

I suspect more and more that something is wrong with those Templates.
Can you create one from scratch with the New-Template cmdlet?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
chrismanuele
Contributor
Contributor

I created a new VM then from that created a new Template. Using that template I tried to create a VM from template and received the same error. The VM I created doesn't have an OS, but it does power on. I was able to manually create a new VM by deploying from the template.

PS C:\Windows\System32> New-VM -Name 'CLI-Template' -VMHost $VMHost -Datastore $DataStore -NumCPU 2 -MemoryGB 4 -DiskGB 60 -NetworkName "VLAN13 - QA-DEV" -DiskStorageFormat Thin

Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
CLI-Template PoweredOff 2 4.000


PS C:\Windows\System32> $OldVM = Get-VM -Name 'CLI-Template'
PS C:\Windows\System32> $DevOpsFolder = Get-Folder -Name 'DevOps' -Location $TemplateFolder
PS C:\Windows\System32> New-Template -VM $OldVM -Location $DevOpsFolder -Name 'CM-Template' -Datastore $DataStore

Name
----
CM-Template


PS C:\Windows\System32> $Template = Get-Template -Datastore $DataStore -Name 'CM-Template'
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/11/2021 11:03:25 AM New-VM
At line:1 char:1
+ New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], InvalidProperty
+ FullyQualifiedErrorId : ViCore_Util10_EncryptionServiceHelper_UpdateViewData_ViErrror,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template 'CM-Template' -VMHost $VMHost -Datastore $DataStore
New-VM : 8/11/2021 11:04:22 AM New-VM
At line:1 char:1
+ New-VM -Name 'CM-NewVM' -Template 'CM-Template' -VMHost $VMHost -Data ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], InvalidProperty
+ FullyQualifiedErrorId : ViCore_Util10_EncryptionServiceHelper_UpdateViewData_ViErrror,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

0 Kudos
LucD
Leadership
Leadership

I'm afraid I have no further ideas on what could cause this in your environment.

It would be best to open an SR.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Hzhang21
Contributor
Contributor

Hi , do you fix this issue now? I have same issue as yours.

0 Kudos