Syntax
Copy-VMGuestFile [-Source] <String[]> [-Destination] <String> -LocalToGuest [-Force] [-VM] <VirtualMachine[]> [-HostCredential <PSCredential>] [-HostUser <String>] [-HostPassword <SecureString>] [-GuestCredential <PSCredential>] [-GuestUser <String>] [-GuestPassword <SecureString>] [-ToolsWaitSecs <Int32>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]Related Commands
Online versionDetailed Description
Copies file and folders from and to the guest OS of the specified virtual machines using VMware Tools. If a file with the same name exists in the destination directory, it is overwritten. Use the GuestUser and GuestPassword, or GuestCredential parameters to authenticate when connecting to the VMware Tools. To authenticate with the host, use the HostUser and HostPassword, or HostCredential parameters. SSPI is not supported. This cmdlet supports only Windows XP 32 SP3, Windows Server 2003 32bit SP2, Windows Server 2003 64bit SP2, Windows 7 64 bit, Windows Server 2008 R2 64bit and Redhat Enterprise 5 operating systems.Parameters
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Source | String[] | Specify the file you want to copy. If the file is on a virtual machine, specify the absolute file path. Relative file paths are supported only when copying files from a local storage. Wildcards are allowed only at the end of the source path. If you are copying files from the guest operating system of a virtual machine to a local directory, the Source parameter supports wildcards only on vCenter Server 5.0 and later. | true | true (ByPropertyName) | |
| Destination | String | Specify the destination path where you want to copy the file. If the destination points to a virtual machine, specify the absolute file path. Relative destination paths are supported only when copying files to a local storage. | true | false | |
| VM | VirtualMachine[] | Specify the virtual machine where the file is located. | true | true (ByValue) | |
| Confirm | SwitchParameter | If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation. | false | false | $true |
| Force | SwitchParameter | Indicate that the non-existing directories in the specified destination path are automatically created. | false | false | |
| GuestCredential | PSCredential | Specify a PSCredential object that contains credentials for authenticating with the guest OS where the file to be copied is located. | false | false | |
| GuestPassword | SecureString | Specify the password you want to use for authenticating with the guest OS where the file to be copied is located. | false | false | |
| GuestToLocal | SwitchParameter | Indicate that you want to copy a file from the guest operating system of the virtual machine to a local directory. | true | false | |
| GuestUser | String | Specify the user name you want to use for authenticating with the guest OS where the file to be copied is located. | false | false | |
| HostCredential | PSCredential | Specify a PSCredential object that contains credentials for authenticating with the host where the file is to be copied. Do not use this parameter if the -HostUser and -HostPassword parameters are used. You need to specify host credentials only if the version of the vCenter Server or ESX you are authenticating with is earlier than 4.0, or the VIX version you have installed is earlier than 1.10. | false | false | |
| HostPassword | SecureString | Specify the password you want to use for authenticating with the host where the file is to be copied. You need to specify host credentials only if the version of the vCenter Server or ESX you are authenticating with is earlier than 4.0, or the VIX version you have installed is earlier than 1.10. | false | false | |
| HostUser | String | Specify the user name you want to use for authenticating with the host where the file is to be copied. You need to specify host credentials only if the version of the vCenter Server or ESX you are authenticating with is earlier than 4.0, or the VIX version you have installed is earlier than 1.10. | false | false | |
| LocalToGuest | SwitchParameter | Indicate that you want to copy a file from a local directory to the guest operating system of the virtual machine. | true | false | $true |
| Server | VIServer[] | Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. | false | false | |
| ToolsWaitSecs | Int32 | Specify the time in seconds to wait for a response from the VMware Tools. If a non-positive value is provided, the system waits infinitely long time. | false | false | 20 |
| WhatIf | SwitchParameter | Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified. | false | false |
Return Type
Notes
Supported only on ESX 3.5 Update 2 and later. This cmdlet works only in 32-bit mode.Examples
-------------- Example 1 --------------
Copy-VMGuestFile -Source c:\text.txt -Destination c:\temp\ -VM VM -GuestToLocal -HostUser root -HostPassword pass1 -GuestUser user -GuestPassword pass2
Copies the text.txt file from the guest OS system to the local Temp directory.
-------------- Example 2 --------------
$vm = Get-VM -Name VM Get-Item "c:\FolderToCopy\*.*" | Copy-VMGuestFile -Destination "c:\MyFolder" -VM $vm -LocalToGuest -HostUser User -HostPassword pass1 -GuestUser -GuestPassword pass2
Copies files from a local machine to a guest operating system.