< Back
Copy-VMGuestFile
Post
NAME Copy-VMGuestFile
SYNOPSIS
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware Tools.
SYNTAX
Copy-VMGuestFile [-Source] <String[]> [-Destination] <String> [-VM] <VirtualMachine[]> [-Force] [-GuestCredential
<PSCredential>] [-GuestPassword <SecureString>] -GuestToLocal [-GuestUser <String>] [-HostCredential
<PSCredential>] [-HostPassword <SecureString>] [-HostUser <String>] [-Server <VIServer[]>] [-ToolsWaitSecs
<Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Copy-VMGuestFile [-Source] <String[]> [-Destination] <String> [-VM] <VirtualMachine[]> [-Force] [-GuestCredential
<PSCredential>] [-GuestPassword <SecureString>] [-GuestUser <String>] [-HostCredential <PSCredential>]
[-HostPassword <SecureString>] [-HostUser <String>] -LocalToGuest [-Server <VIServer[]>] [-ToolsWaitSecs <Int32>]
[-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware
Tools. 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. For a list of supported operating systems, see the PowerCLI User's Guide.
To run this cmdlet against vCenter Server/ESX/ESXi versions earlier than 5.0, you need to meet the following
requirements: *You must run the cmdlet on the 32-bit version of Windows PowerShell. *You must have access to the
ESX that hosts the virtual machine over TCP port 902. *For vCenter Server/ESX/ESXi versions earlier than 4.1, you
need VirtualMachine.Interact.ConsoleInteract privilege. For vCenter Server/ESX/ESXi 4.1 and later, you need
VirtualMachine.Interact.GuestControl privilege.
To run this cmdlet against vCenter Server/ESXi 5.0 and later, you need VirtualMachine.GuestOperations.Modify
privilege.
PARAMETERS
-Destination <String>
Specifies 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.
Required? true
Position? 2
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that the non-existing directories in the specified destination path are automatically created.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GuestCredential <PSCredential>
Specifies 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 None
Accept pipeline input? False
Accept wildcard characters? false
-GuestPassword <SecureString>
Specifies the password you want to use for authenticating with the guest OS where the file to be copied is
located.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-GuestToLocal [<SwitchParameter>]
Indicates that you want to copy a file from the guest operating system of the virtual machine to a local
directory.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GuestUser <String>
Specifies the user name you want to use for authenticating with the guest OS where the file to be copied is
located.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostCredential <PSCredential>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostPassword <SecureString>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostUser <String>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-LocalToGuest [<SwitchParameter>]
Indicates that you want to copy a file from a local directory to the guest operating system of the virtual
machine.
Required? true
Position? named
Default value $true
Accept pipeline input? False
Accept wildcard characters? false
-Server <VIServer[]>
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this
parameter, the command runs on the default servers. For more information about default servers, see the
description of Connect-VIServer.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Source <String[]>
Specifies the file you want to copy. If the file is on a virtual machine, specifies 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.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-ToolsWaitSecs <Int32>
Specifies 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
-VM <VirtualMachine[]>
Specifies the virtual machine where the file is located.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-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.
Required? false
Position? named
Default value $true
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are
modified.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
None
NOTES
-------------------------- Example 1 --------------------------
Copy-VMGuestFile -Source c:\\text.txt -Destination c:\\temp\\ -VM VM -GuestToLocal -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 -GuestUser
-GuestPassword pass2
Copies files from a local machine to a guest operating system.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... tFile.html
SYNOPSIS
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware Tools.
SYNTAX
Copy-VMGuestFile [-Source] <String[]> [-Destination] <String> [-VM] <VirtualMachine[]> [-Force] [-GuestCredential
<PSCredential>] [-GuestPassword <SecureString>] -GuestToLocal [-GuestUser <String>] [-HostCredential
<PSCredential>] [-HostPassword <SecureString>] [-HostUser <String>] [-Server <VIServer[]>] [-ToolsWaitSecs
<Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Copy-VMGuestFile [-Source] <String[]> [-Destination] <String> [-VM] <VirtualMachine[]> [-Force] [-GuestCredential
<PSCredential>] [-GuestPassword <SecureString>] [-GuestUser <String>] [-HostCredential <PSCredential>]
[-HostPassword <SecureString>] [-HostUser <String>] -LocalToGuest [-Server <VIServer[]>] [-ToolsWaitSecs <Int32>]
[-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware
Tools. 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. For a list of supported operating systems, see the PowerCLI User's Guide.
To run this cmdlet against vCenter Server/ESX/ESXi versions earlier than 5.0, you need to meet the following
requirements: *You must run the cmdlet on the 32-bit version of Windows PowerShell. *You must have access to the
ESX that hosts the virtual machine over TCP port 902. *For vCenter Server/ESX/ESXi versions earlier than 4.1, you
need VirtualMachine.Interact.ConsoleInteract privilege. For vCenter Server/ESX/ESXi 4.1 and later, you need
VirtualMachine.Interact.GuestControl privilege.
To run this cmdlet against vCenter Server/ESXi 5.0 and later, you need VirtualMachine.GuestOperations.Modify
privilege.
PARAMETERS
-Destination <String>
Specifies 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.
Required? true
Position? 2
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that the non-existing directories in the specified destination path are automatically created.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GuestCredential <PSCredential>
Specifies 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 None
Accept pipeline input? False
Accept wildcard characters? false
-GuestPassword <SecureString>
Specifies the password you want to use for authenticating with the guest OS where the file to be copied is
located.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-GuestToLocal [<SwitchParameter>]
Indicates that you want to copy a file from the guest operating system of the virtual machine to a local
directory.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-GuestUser <String>
Specifies the user name you want to use for authenticating with the guest OS where the file to be copied is
located.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostCredential <PSCredential>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostPassword <SecureString>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-HostUser <String>
Specifies 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-LocalToGuest [<SwitchParameter>]
Indicates that you want to copy a file from a local directory to the guest operating system of the virtual
machine.
Required? true
Position? named
Default value $true
Accept pipeline input? False
Accept wildcard characters? false
-Server <VIServer[]>
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this
parameter, the command runs on the default servers. For more information about default servers, see the
description of Connect-VIServer.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Source <String[]>
Specifies the file you want to copy. If the file is on a virtual machine, specifies 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.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-ToolsWaitSecs <Int32>
Specifies 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
-VM <VirtualMachine[]>
Specifies the virtual machine where the file is located.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-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.
Required? false
Position? named
Default value $true
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are
modified.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
None
NOTES
-------------------------- Example 1 --------------------------
Copy-VMGuestFile -Source c:\\text.txt -Destination c:\\temp\\ -VM VM -GuestToLocal -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 -GuestUser
-GuestPassword pass2
Copies files from a local machine to a guest operating system.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... tFile.html