powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Copy-VMGuestFile



NAME
Copy-VMGuestFile

SYNOPSIS
Copies files and folders from and to the guest OS of the specified virtual machines using VMware Tools.

SYNTAX
Copy-VMGuestFile [-Source] [-Destination] -LocalToGuest [-Force] [-VM] [-Hos
tCredential ] [-HostUser ] [-HostPassword ] [-GuestCredential ] [
-GuestUser ] [-GuestPassword ] [-ToolsWaitSecs ] [-Server ] [-WhatIf] [-Co
nfirm] []

Copy-VMGuestFile [-Source] [-Destination] -GuestToLocal [-Force] [-VM] [-Hos
tCredential ] [-HostUser ] [-HostPassword ] [-GuestCredential ] [
-GuestUser ] [-GuestPassword ] [-ToolsWaitSecs ] [-Server ] [-WhatIf] [-Co
nfirm] []


DESCRIPTION
Copies file and folders from and to the guest OS of the specified virtual machines using VMware Tools. If a file wi
th the same name exists in the destination directory, it is overwritten. Use the GuestUser and GuestPassword, or Gu
estCredential parameters to authenticate when connecting to the VMware Tools. To authenticate with the host, use th
e 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
-Source
Specify the file you want to copy. If the file is on a virtual machine, specify the absolute file path. Relativ
e 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 di
rectory, the Source parameter supports wildcards only on vCenter Server 5.0 and later.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? true

-Destination
Specify the destination path where you want to copy the file. If the destination points to a virtual machine, s
pecify the absolute file path. Relative destination paths are supported only when copying files to a local stor
age.

Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-LocalToGuest
Indicate that you want to copy a file from a local directory to the guest operating system of the virtual machi
ne.

Required? true
Position? named
Default value $true
Accept pipeline input? false
Accept wildcard characters? false

-Force
Indicate that the non-existing directories in the specified destination path are automatically created.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-VM
Specify the virtual machine where the file is located.

Required? true
Position? 3
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-HostCredential
Specify a PSCredential object that contains credentials for authenticating with the host where the file is to b
e 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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-HostUser
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 ea
rlier than 4.0, or the VIX version you have installed is earlier than 1.10.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-HostPassword
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 ear
lier than 4.0, or the VIX version you have installed is earlier than 1.10.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestCredential
Specify a PSCredential object that contains credentials for authenticating with the guest OS where the file to
be copied is located.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestUser
Specify the user name you want to use for authenticating with the guest OS where the file to be copied is locat
ed.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestPassword
Specify the password you want to use for authenticating with the guest OS where the file to be copied is locate
d.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value 20
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value $true
Accept pipeline input? false
Accept wildcard characters? false

-GuestToLocal
Indicate that you want to copy a file from the guest operating system of the virtual machine to a local directo
ry.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS



NOTES


Supported only on ESX 3.5 Update 2 and later.
This cmdlet works only in 32-bit mode.

-------------- Example 1 --------------

C:\PS>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 --------------

C:\PS>$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.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Copy-VMGuestFile.html