Automation

 View Only
  • 1.  Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 08:38 AM

    Hi all,

    I have had PowerCLI in version 4.1 and I have upgraded it to 5.1 because of new amazing features.

    In the 4.1 version I was copping files with following command:

    Copy-VMGuestFile -LocalToGuest -Source "C:\powcli41.txt" -Destination "C:\Users\unittester\Desktop\powcli41.txt" -VM VMName -GuestUser domain\username -GuestPassword password -HostUser username -HostPassword password -force

    and it was working perfect.

    In the 5.0 and 5.1 versions on the VM I can see extra, unnecessary folder:

    C:\Users\unittester\Desktop\powcli41.txt\powcli41.txt

    instead of required

    C:\Users\unittester\Desktop\powcli41.txt

    Could You explain how to modify Copy-VMGuestFlie command to avoid getting superfluous powcli41.txt folder?

    Regards,
    Przemyslaw Sech



  • 2.  RE: Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 09:14 AM

    To be honest I never specified a file on the Destination parameter, only a folder.

    In PowerCLI 5.* the cmdlet seems to work as I would expect it to work, it interpretes the filename you provided as a folder.

    If the behaviour in PowerCLI 4.* was as you described, I would consider that as a bug, not what is now done in PowerCLI 5.*



  • 3.  RE: Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 09:22 AM

    I forgot to add why I am using -Destination path with file name on the end.

    The case is to copy and rename file.

    It was working in PowerCLI 4.1.



  • 4.  RE: Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 09:51 AM

    Just did some tests, and indeed there seems to be an inconsistency in the behaviour of the cmdlet.

    With GuestToLocal everything works as expected. When I specify a filename on the Destination, there is no additional folder and the file is renamed.

    With LocalToGuest I have the same phenomena you see. Without a filename in the destination path, everything works ok. But when I specify a filename, to do a rename, I get the extra folder as well.

    When I execute with the Verbose parameter, the cmdlet even shows the correct destination, but the file ends up in a folder with it's original name.

    It seems you discovered a "feature" :smileywink:



  • 5.  RE: Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 10:43 AM

    That is great we are on the same side, but it does not solve my problem :smileywink:.

    Do you know some workaround how to change file name after copping to VM?



  • 6.  RE: Copy-VMGuestFile creates superfluous folders
    Best Answer

    Posted Oct 02, 2012 10:58 AM

    You could do something like this

    Copy-VMGuestFile -LocalToGuest -VM $vm -Source C:\test.txt -Destination C:\Temp\ 
    Invoke-VMScript
    -VM $vm -ScriptType bat -ScriptText "move /Y c:\Temp\test.txt c:\Temp\anothername.txt"


  • 7.  RE: Copy-VMGuestFile creates superfluous folders

    Posted Oct 02, 2012 02:08 PM

    Hi Przemyslaw and Luc,

    I too think that it's a bug. I filed it in the internal bugtracking system so it will get proper attention from the development team.

    Thank you guys for taking some of your time to help make PowerCLI better!