VMware Cloud Community
dcoz
Hot Shot
Hot Shot

copy-datastore item

Hi Guys,

I am trying to copy a test file to the local VMFS volume of an ESX host is have.

I have created a simple script to do this, but the file does not copy although the command completes successfully.

Any ideas?

$ds = get-VMHost test01 | get-Datastore "test01_vmfs_local"
copy-DatastoreItem "c:\temp\test.txt" $ds.DatastoreBrowserPath

Thanks

Dougie

Tags (2)
0 Kudos
1 Reply
mattboren
Expert
Expert

Hello, Dougie-

It seems like the issue you are having is with trying to write to the root of the datastore.  I have the same issue, and have seen other posts about not being able to do so -- a limitation of the cmdlet, it seems.

So, how about if you try to write to a subfolder on the datastore?  Like:

Copy-DatastoreItem "c:\temp\test.txt" "$($ds.DatastoreBrowserPath)\someFolder\."
dir "$($ds.DatastoreBrowserPath)\someFolder"

And, you may already know, but you should not need to do the "Get-VMHost" part of your first line, "Get-VMHost test01 | Get-Datastore...", unless you have multiple datastores by the name "test01_vmfs_local" -- just the "Get-Datastore test01_vmfs_local" should suffice.

Are you able to copy a datastore item to a subfolder?

0 Kudos