jferrua
Contributor
Contributor

Download a file from a local datastore

Jump to solution

Hello all,

I was wondering if it is possible to script the download of a file from a local datastore to a Windows server? Also, are there any scripts available to perform such a task?

Thanks

0 Kudos
1 Solution

Accepted Solutions
ae_jenkins
Enthusiast
Enthusiast

Hi

Just figured it out myself using the copy-datastoreitem cmdlet - good KB article here

After connecting to you vCenter server, connect to the datastore in question, and mount the source datastore as a PSdrive, then use the cmdlet.  It works both uploading to a datastore and downloading from a datastore:  Just switch around the objects in -Item and -Destination.

At first glance, it looks like you have to know the source path of the datastore.

$dstore = get-datastore "YourDatastoreName"

New-PSDrive -location $dstore -name dStore -psprovider vimdatastore -root '\'

copy-datastoreitem -item dStore:\VMFolder\VMConfig.vmx -Destination c:\SomeFolder\vmconfig.vmx

View solution in original post

0 Kudos
2 Replies
ae_jenkins
Enthusiast
Enthusiast

Hi

Just figured it out myself using the copy-datastoreitem cmdlet - good KB article here

After connecting to you vCenter server, connect to the datastore in question, and mount the source datastore as a PSdrive, then use the cmdlet.  It works both uploading to a datastore and downloading from a datastore:  Just switch around the objects in -Item and -Destination.

At first glance, it looks like you have to know the source path of the datastore.

$dstore = get-datastore "YourDatastoreName"

New-PSDrive -location $dstore -name dStore -psprovider vimdatastore -root '\'

copy-datastoreitem -item dStore:\VMFolder\VMConfig.vmx -Destination c:\SomeFolder\vmconfig.vmx

View solution in original post

0 Kudos
jferrua
Contributor
Contributor

Exactly what I was looking for. Thank you so much!

0 Kudos