New-VM -DiskPath

This post was originally published on this site

I’m trying to deploy a VM in esxi 6.5 and I have an existing vmdk in one of the datastores.

Below is the script I used,

 

$vmhost = Get-VMHost -Name 10.91.91.219

New-VM -Name ‘TestVM’ -ResourcePool $vmhost -Datastore ‘datastore1’ -DiskPath ‘[datastore] Testing/Testing.vmdk’

 

After running the ‘ps1’ file which contains the above script, powershell throws an error as,

 

PS C:Windowssystem32> C:test.ps1

New-VM : 8/11/2020 12:22:45 PM New-VM The disk path “[datastore] Testing/Testing.vmdk” is invalid.

At C:test.ps1:2 char:1

+ New-VM -Name ‘TestVM’ -ResourcePool $vmhost -Datastore ‘datastore1’ – …

+ ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: ([datastore] Testing/Testing.vmdk:String) [New-VM], InvalidDatastoreP

   ath

    + FullyQualifiedErrorId : Client20_VMServiceImpl_TryValidateVmDiskPath_InvalidDiskPath,VMware.VimAutomation.ViCo

   re.Cmdlets.Commands.NewVM

 

Please help me with a proper syntax to deploy a new VM.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.