VMware Cloud Community
vin01
Expert
Expert
Jump to solution

Unable to upload file to datastore

Hello

Can some one help me on this I'm trying to upload a folder to local datastore on esxi host but its failing

used as below

$ds = Get-Datacenter "test" |Get-Folder "CISCO UCS B200 M3"|Get-VMHost |Get-Datastore "datastore*"

$destination = "\"

$source = 'D:\All Cisco\ENICandFNIC Drives for UCSver2.2.C\updated drivers' -- this folder

New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root $destination

Set-Location ds:\

Copy-DatastoreItem -Item $source -Destination $destination

Regards Vineeth.K
0 Kudos
1 Solution

Accepted Solutions
Wh33ly
Hot Shot
Hot Shot
Jump to solution

What error messages do you get? When I execute your script, only an empty folder is made on the datastore. When you add  "-recurse" it also copies the child items (files and directories)

$ds = Get-Datacenter "test" |Get-Folder "CISCO UCS B200 M3"|Get-VMHost |Get-Datastore "datastore*"
$destination = "\" 
$source = 'D:\Test ' # -- this folder
New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root $destination 
Set-Location ds:\ New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root $destination 
Copy-DatastoreItem -Item $source -Destination $destination -Recurse

But that is only 1 datastore, as I understand from your example, you're trying to copy to different datastores. This could be easily done like this :

$DS = Get-Datacenter "test" |Get-Folder "CISCO UCS B200 M3"|Get-VMHost |Get-Datastore "datastore*" | select name,DatastoreBrowserPath 
$source = 'D:\Test ' # -- this folder                                                              
 foreach ($datastore in $ds){ 
Copy-DatastoreItem -Item $source -Destination  $datastore.DatastoreBrowserPath -Recurse
}

View solution in original post

0 Kudos
2 Replies
Wh33ly
Hot Shot
Hot Shot
Jump to solution

What error messages do you get? When I execute your script, only an empty folder is made on the datastore. When you add  "-recurse" it also copies the child items (files and directories)

$ds = Get-Datacenter "test" |Get-Folder "CISCO UCS B200 M3"|Get-VMHost |Get-Datastore "datastore*"
$destination = "\" 
$source = 'D:\Test ' # -- this folder
New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root $destination 
Set-Location ds:\ New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root $destination 
Copy-DatastoreItem -Item $source -Destination $destination -Recurse

But that is only 1 datastore, as I understand from your example, you're trying to copy to different datastores. This could be easily done like this :

$DS = Get-Datacenter "test" |Get-Folder "CISCO UCS B200 M3"|Get-VMHost |Get-Datastore "datastore*" | select name,DatastoreBrowserPath 
$source = 'D:\Test ' # -- this folder                                                              
 foreach ($datastore in $ds){ 
Copy-DatastoreItem -Item $source -Destination  $datastore.DatastoreBrowserPath -Recurse
}
0 Kudos
vin01
Expert
Expert
Jump to solution

Great Now its working perfectly Smiley Happy Is it possible to upload any file to esx host /tmp folder from my local desktop using powercli.Why i'm asking because i trying to upload drivers to localdatastore i.e .vib file from there i'm trying to install using $esxcli.software.vib.install but it fails but keeping the file in /tmp installation going sucessfully.

=====

Used script

$esxcli= Get-Esxcli -vmHost 10.xx.xx.xx

$ciscovibpath="/datastore1 (12)/fnic_driver_1.6.0.10-1899655/scsi-fnic-1.6.0.10-1OEM.500.0.0.472560.x86_64.vib"

$esxcli.software.vib.install($null,$null,$null,$null,$null,$null,$null,$null,$ciscovibpath)

==============================================================

Message:  [VibDownloadError];

InnerText:  [VibDownloadError] ('/vmfs/volumes/datastore1 \\\\\\(12\\)\\\\/fnic

_driver_1.6.0.10-1899655/scsi-fnic-1.6.0.10-1OEM.500.0.0.472560.x86_64.vib', ''

, "[Errno 4] IOError: <urlopen error [Errno 2] No such file or directory: '/vmf

s/volumes/datastore1 \\\\\\\\\\\\(12\\\\)\\\\\\\\/fnic_driver_1.6.0.10-1899655/

scsi-fnic-1.6.0.10-1OEM.500.0.0.472560.x86_64.vib'>")        url = /vmfs/volume

s/datastore1 \\\(12\)\\/fnic_driver_1.6.0.10-1899655/scsi-fnic-1.6.0.10-1OEM.50

0.0.0.472560.x86_64.vib Please refer to the log file for more details.EsxCLI.CL

IFault.summary

At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vibinstall.ps1:5 cha

r:29

+ $esxcli.software.vib.install <<<< ($null,$null,$null,$null,$null,$null,$null,

$null,$ciscovibpath)

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : MethodInvocationException

========================

If i try like this it works ..

$esxcli= Get-Esxcli -vmHost 10.xx.xx.xx

$ciscovibpath="/tmp/fnic_driver_1.6.0.10-1899655/scsi-fnic-1.6.0.10-1OEM.500.0.0.472560.x86_64.vib"

$esxcli.software.vib.install($null,$null,$null,$null,$null,$null,$null,$null,$ciscovibpath)

Regards Vineeth.K
0 Kudos