Windows Machine File Copy task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015

Use this task to copy application files and other artifacts such as PowerShell scripts and PowerShell-DSC modules that are required to install the application on Windows Machines. It uses RoboCopy, the command-line utility built for fast copying of data.


In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

YAML snippet

# Windows machine file copy
# Copy files to remote Windows machines
- task: WindowsMachineFileCopy@2
    #machineNames: # Optional
    #adminUserName: # Optional
    #adminPassword: # Optional
    #cleanTargetBeforeCopy: false # Optional
    #copyFilesInParallel: true # Optional
    #additionalArguments: # Optional


Argument Description
Source The path to the files to copy. Can be a local physical path such as c:\files or a UNC path such as \\myserver\fileshare\files. You can use pre-defined system variables such as $(Build.Repository.LocalPath) (the working folder on the agent computer), which makes it easy to specify the location of the build artifacts on the computer that hosts the automation agent.
Machines A comma-separated list of machine FQDNs or IP addresses, optionally including the port number. Can be:
- The name of an Azure Resource Group.
- A comma-delimited list of machine names. Example:,,192.168.34:5986
- An output variable from a previous task.
Admin Login The username of either a domain or a local administrative account on the target host(s).
- Formats such as domain\username, username, and machine-name\username are supported.
- UPN formats such as and built-in system accounts such as NT Authority\System are not supported.
Password The password for the administrative account specified above. Consider using a secret variable global to the build or release pipeline to hide the password. Example: $(passwordVariable)
Destination Folder The folder on the Windows machine(s) to which the files will be copied. Example: C:\FabrikamFibre\Web
Advanced - Clean Target Set this option to delete all the files in the destination folder before copying the new files to it.
Advanced - Copy Files in Parallel Set this option to copy files to all the target machines in parallel, which can speed up the copying process.
Advanced - Additional Arguments Arguments to pass to the RoboCopy process. Example: /min:33553332 /l
Select Machines By Depending on how you want to specify the machines in the group when using the Filter Criteria parameter, choose Machine Names or Tags.
Filter Criteria Optional. A list of machine names or tag names that identifies the machines that the task will target. The filter criteria can be:
- The name of an Azure Resource Group.
- An output variable from a previous task.
- A comma-delimited list of tag names or machine names.
Format when using machine names is a comma-separated list of the machine FQDNs or IP addresses.
Specify tag names for a filter as {TagName}:{Value} Example: Role:DB;OS:Win8.1
Control options See Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.


I get a system error 53 when using this task. Why?

Typically this occurs when the specified path cannot be located. This may be due to a firewall blocking the necessary ports for file and printer sharing, or an invalid path specification. For more details, see Error 53 on TechNet.

Do I need an agent?

You need at least one agent to run your build or release.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.