VMware Cloud Community
pakeha
Contributor
Contributor

Copy-VMGuestFile -LocalToGuest overwriting files

Hi all,


I'm attempting to copy files between two locations on a regular basis using the Copy-VMGuestFile cmdlet. My reason for having to use this command is due to the destination server being in our DMZ and there's no route between my host. However I'm having an issue with overwriting files on the destination VM and I am receiving the following error:

Error

VCENTRE                      443  user         

Copy-VMGuestFile : 8/07/2015 10:33:37 a.m.    Copy-VMGuestFile        Cannot complete the operation because the file or folder E:\Website\ already exists

At C:\Users\user\Desktop\test.ps1:19 char:1

+ Copy-VMGuestFile  -VM HOST -LocalToGuest -Source C:\Users\*\Desktop ...

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

    + CategoryInfo          : NotSpecified: (:) [Copy-VMGuestFile], FileAlreadyExists

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_CreateDirectoryInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyVMGuestFile

Copy-VMGuestFile : 8/07/2015 10:33:39 a.m.    Copy-VMGuestFile        Cannot complete the operation because the file or folder E:\Website\ already exists

At C:\Users\user\Desktop\test.ps1:19 char:1

+ Copy-VMGuestFile  -VM HOST -LocalToGuest -Source C:\Users\user\Desktop ...

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

    + CategoryInfo          : NotSpecified: (:) [Copy-VMGuestFile], FileAlreadyExists

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_CreateDirectoryInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyVMGuestFile

I've referenced the PowerCLI documentation found here: vSphere 5.5 Documentation Center ‌and it states: "If a file with the same name exists in the destination directory, it is overwritten." But there is no mention of  overwriting directories.. I've tried Googling and searching the forums but no results have shown up.


The command I'm using is: Copy-VMGuestFile -VM $DestinationVM -LocalToGuest -Source $SourceFile -Destination $DestinationFile -HostUser $Username -HostPassword $Password -force

Any assistance on this matter would be greatly appreciated.

Cheers,

Judge

0 Kudos
2 Replies
pakeha
Contributor
Contributor

I was caught out by the incorrect syntax.. After changing -HostUser and -HostPassword to -GuestUser and -GuestPassword respectively, the folders were able to be overwritten (doh!).

0 Kudos
laslite
Contributor
Contributor

Hi pakeha,

If you transfer files regularly, I can suggest you try this application.

https://guest-file-transfert-tools-vmware.nicolas-hypolite.fr/update/EASY_Guest_File_Tranfert_Tools_...

It is under development but the file transfer function works Smiley Happy

Best regards.

0 Kudos