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
22 Replies
LucD
Leadership
Leadership

Which PowerCLI and PowerShell versions are you using?


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

0 Kudos
chrismanuele
Contributor
Contributor

Currently using Powershell 5.1 and PowerCli 12.3. Should I attempt upgrading PowerShell to v7.1?

PS C:\Windows\System32> Get-Host | Select-Object Version

Version
-------
5.1.14393.4530


PS C:\Windows\System32> Get-Module -Name VMware.*

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 7.0.2.1... VMware.Vim
Script 12.3.0.... VMware.VimAutomation.Cis.Core {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script 12.3.0.... VMware.VimAutomation.Common {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, Stop-Task...}
Script 12.3.0.... VMware.VimAutomation.Core {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer...}
Script 12.2.0.... VMware.VimAutomation.Sdk {Get-ErrorReport, EnableParameterCompleters, Get-InstallPath, Get-PSVersion}

0 Kudos
LucD
Leadership
Leadership

No, that PS version is OK.

Are these datastores with the same name on different vCenters?


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

0 Kudos
chrismanuele
Contributor
Contributor

Hello,

I think they are technically the same Datastore linked to two DataCenters in a single vCenter.

chrismanuele_0-1627926957702.png

 

 

0 Kudos
LucD
Leadership
Leadership

Is there a warning on that Datastore?

Why did you conclude it is a "type mismatch"?
Does the New-VM cmdlet produce the same error on any other datastore passed in a variable?
Is there anything in the vpxd log that provides more details about the error?


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

0 Kudos
chrismanuele
Contributor
Contributor

The warning is "Datastore usage on disk." The description for the alarm says, "Default alarm to monitor datastore disk usage." That doesn't sound related but I'm not sure.

I'm not familiar with the vpxd log. Where can I find that?

I thought it might be a type mismatch because of what I was reading in the documentation. The New-VM command takes type <StorageResource> for the -Datastore parameter. The Get-DataStore command returns a <Datastore> type. 

I have tried sending the output of the Get-DataStore command to send in the DataStore I want as a parameter to New-VM 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

0 Kudos
LucD
Leadership
Leadership

Is there sufficient free storage on the Datastore?

The vpxd log is located on the VCSA, under /var/log/vmware/


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

0 Kudos
chrismanuele
Contributor
Contributor

There's a TB of free space on the DataStore.

However, the problem might not be the DataStore. It might be the Template.

This command succeeded:
New-VM -Name 'CM-NewVM' -VMHost $VMHost -Datastore $DataStore

When I add the template in:

PS C:\Windows\System32> Get-Template -Datastore $DataStore -Name DEPLOY-W19-DB19

Name
----
DEPLOY-W19-DB19

PS C:\Windows\System32> $Template = Get-Template -Datastore $DataStore -Name DEPLOY-W19-DB19
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/2/2021 12:10:04 PM 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

As far as I can tell, the $Template variable is valid and is what is expected for the -Template parameter. 

 

0 Kudos
LucD
Leadership
Leadership

Can you test with another template?


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

0 Kudos
chrismanuele
Contributor
Contributor

Tried with some other templates without any luck:

PS C:\Windows\System32> $Template = Get-Template -Datastore $DataStore -Name Server-2019
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/2/2021 1:29:38 PM 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> $Template = Get-Template -Datastore $DataStore -Name DEPLOY-W16-DB17
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/2/2021 1:31:53 PM 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> $Template = Get-Template -Datastore $DataStore -Name Server-2016
PS C:\Windows\System32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/2/2021 1:32:52 PM 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

0 Kudos
LucD
Leadership
Leadership

Strange, never saw that.

Can you create a new VM from any of those Templates via the Web Client?


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

0 Kudos
chrismanuele
Contributor
Contributor

I can deploy from them through the Thick client. We don't utilize the web client since it is Flash based.

0 Kudos
LucD
Leadership
Leadership

Are you on an older vSphere version?
That HTML client is available since vSphere 6.5


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

0 Kudos
chrismanuele
Contributor
Contributor

We are using VMware vCenter Server 5.5.0, 3000241 

0 Kudos
chrismanuele
Contributor
Contributor

All of our templates were created manually through vSphere. Would that make a difference? I'll try making a new Template via PowerCLI and see if that makes a difference.

0 Kudos
LucD
Leadership
Leadership

It would be worth a try, I have no clue what could be the cause.


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

0 Kudos
LucD
Leadership
Leadership

This is really an old version, and not supported anymore I'm afraid.
So no option to open an SR


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

0 Kudos
chrismanuele
Contributor
Contributor

I was able to try on a v6.0.0 vCenter environment and the result was the same. 

PS C:\Windows\system32> $Global:DefaultVIServer | select Name, Version, Build

Name Version Build
---- ------- -----
inkaba-vsphere2.leicabio.com 6.0.0 13638472


PS C:\Windows\system32> New-VM -Name 'CM-NewVM' -VMHost $VMHost -Datastore $DataStore

Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
CM-NewVM PoweredOff 1 0.250


PS C:\Windows\system32> New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : Cannot validate argument on parameter 'Template'. The argument is null. Provide a valid value for the argument, and then try
running the command again.
At line:1 char:35
+ New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastor ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-VM], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

 

0 Kudos
chrismanuele
Contributor
Contributor

I attempted to create a new Template from our existing template. The creation of the new template succeeded, but the New-VM using this new template as a parameter still fails with the same error.

$OldVM = Get-VM -Name 'DEPLOY-W19-DB19'
$TemplateFolder = Get-Folder -Name "Templates"
$DevOpsFolder = Get-Folder -Name 'DevOps' -Location $TemplateFolder
$DataStore = Get-DataStore -Location 'QA/Dev' -Name 'EQL QA-DEV1'
New-Template -VM $OldVM -Location $DevOpsFolder -Name 'CM-Template' -Datastore $DataStore
$Template = Get-Template -Name 'CM-Template'
New-VM -Name 'CM-NewVM' -Template $Template -VMHost $VMHost -Datastore $DataStore
New-VM : 8/5/2021 6:47:15 PM 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/5/2021 6:48:31 PM 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