Search code examples
powershellvmwarepowercli

PowerCLI New-CDDrive - invalid datastore path


I'm trying to mount an iso from a datastore using VMWare PowerCLI. Code example:

$IsoPath = "vmstores:\1.2.2.1900443\datacenter1\datastore1\files.iso"
$cd = New-CDDrive -VM Vm001 -ISOPath $IsoPath

This fails with the error: New-CDDrive The operation for the entity "Vm001" failed with the following message: "Invalid datastore path 'vmstores:\1.2.2.1900443\datacenter1\datastore1\files.iso'

The path is valid. I confirm with:

Get-ChildItem "vmstores:\1.2.2.1900443\datacenter1\datastore1\files.iso"

Output:

Name               Type               Id
----               ----               --
Files.iso          DatastoreFile

What is wrong with the command?


Solution

  • I guess that the vmstores: drive is a PowerShell Provider available on your local system, but the VHost has no idea about it, and the path needs to be in the form it understands, e.g. '[DatastoreName] folder\folder2\file.iso'.