VMware Cloud Community
psech
Contributor
Contributor
Jump to solution

Copy-VMGuestFile creates superfluous folders

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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.*


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
psech
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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" Smiley Wink


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
psech
Contributor
Contributor
Jump to solution

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

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
andrey_anastaso
Enthusiast
Enthusiast
Jump to solution

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!

Reply
0 Kudos