---
title: "Automate File Transfers with PowerShell & Scheduled Tasks"
description: "Set up automated file transfers using PowerShell and create scheduled tasks to run your script on a recurring basis."
canonical: "https://adamtheautomator.com/automated-file-transfer/"
---

# Automate File Transfers with PowerShell & Scheduled Tasks

> Set up automated file transfers using PowerShell and create scheduled tasks to run your script on a recurring basis.

Source: https://adamtheautomator.com/automated-file-transfer/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Automate File Transfers with PowerShell & Scheduled Tasks](https://adamtheautomator.com/wp-content/uploads/2019/07/5d238ae5c824b514689ea65f.jpg)

# Automate File Transfers with PowerShell & Scheduled Tasks

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)1 July 20193 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[File Management](/tag/file-management/)[PowerShell](/tag/powershell/)[Windows Scheduled Tasks](/tag/windows-scheduled-tasks/)

Table of Contents

*   [Create Your Script for Automated File Transfer](#create-your-script)
*   [Create a Scheduled Task](#create-a-scheduled-task)

You shouldn’t have to babysit all of the file copies; [scheduled tasks](https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page) are perfect for automated file transfers.

Related:[How to Set Up and Manage Scheduled Tasks with PowerShell](https://adamtheautomator.com/powershell-scheduled-task/)

Copying files from one place to another is a trivial task no matter how you do it. And there are a number of ways to get the job done: dragging and dropping the file in Windows Explorer, `Copy-Item` with [PowerShell](https://adamtheautomator.com/tag/powershell/) or the simple copy command in DOS.

Related: [Copy-Item: Copying Files like a Boss in PowerShell](https://adamtheautomator.com/copy-item/)

It’s just a matter of specifying a source and a destination path and setting a few other optional parameters. It’s only when you start copying a lot of files on a frequent basis that you run into problems.

When automating file copies, especially in a Windows environment, your go-to scripting language is going to be Windows PowerShell. If you need to quickly copy one or more files from one destination to another, PowerShell is a great way to do that. Also, not only is it easy to manually kick off PowerShell scripts, but you can also trigger automated file transfers via PowerShell scripts by using Windows scheduled tasks.

In this article, we’ll go over how to perform file automated file transfers using PowerShell by writing a script and creating a scheduled task to kick off that script on a recurring basis. But before we start, I’m going to assume that you have at least PowerShell v4 installed on your computer. Otherwise, the tricks I’m about to show you may not work properly.

![Windows task scheduler. Great for creating automated file transfer tasks.](https://devblogs.microsoft.com/wp-content/uploads/sites/29/2019/02/hsg-1-15-15-01.png)

Windows task scheduler

## Create Your Script for Automated File Transfer

First, you need to create a script to perform file transfers. Let’s call the script _CopyFiles.ps1_. This script will contain the following code: param(

```powershell
param(
    [string]$SourcePath,
    [string]$DestinationPath
)

Copy-Item -Path $SourcePath -Destination $DestinationPath -Recurse
```

As you can see, the script is simple, but it leaves room for lots of customization depending on your environment.

The most complicated part of this automated file transfer script is the param() section. This is a parameter block containing two parameters: SourcePath and DestinationPath. By making both of these values, parameters allow us to pass in different values to our script so we can reuse it. If `SourcePath` and `DestinationPath` were actual paths, we’d have to create separate scripts for every different file copy!

Manually kicking off this script will look something like this:

```powershell
& .\CopyFiles.ps1 -SourcePath C:\Source -DestinationPath \\SERVER\Destination
```

This example would copy all files and subfolders in the _C:\\Source_ folder to the _\\\\SERVER\\Destination_ shared folder.

## Create a Scheduled Task

Now that you have your _CopyFiles.ps1_ PowerShell script, head over to the computer where you’d like to kick it off. In this example, we’re going to create a scheduled task to run this script once a day at 3 a.m.

You could create scheduled tasks by running the Task Scheduler GUI and creating one that way, but we’re all about automation here. Let’s learn how to create the scheduled task in PowerShell as well. To do this, you’ll need to complete four rough steps:

1.  Create the scheduled task action.
2.  Create the trigger.
3.  Create the scheduled task in memory.
4.  Create the scheduled task on the computer.

Here’s what that looks like in practice. First, we’ll create the automated file transfer scheduled task action. This defines the EXE to run along with any arguments. Here, I’m assuming that your script is located at _C:\\CopyFiles.ps1_.

```powershell
$Action = New-ScheduledTaskAction -Execute 
 
'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -Argument "-NonInteractive -NoLogo -NoProfile -File 'C:\CopyFiles.ps1' -SourcePath 'C:\Source -DestinationPath '\\SERVER\Destination'"
```

Next, we’ll create a trigger to kick it off at 3 a.m. every day.

```powershell
$Trigger = New-ScheduledTaskTrigger -Daily -At '3AM'
```

Next, we’ll create the scheduled task in memory using the action and trigger that we just created.

```powershell
$Task = New-ScheduledTask -Action $Action -Trigger $Trigger -Settings (New-ScheduledTaskSettingsSet)
```

Finally, we’ll actually create the automated file transfer scheduled task on the system, calling it _File Transfer Automation_ and running it under the local administrator account with the provided password.

```powershell
$Task | Register-ScheduledTask -TaskName 'File Transfer Automation' -User 'administrator' -Password 'supersecret'
```

This would register the script, and it will now copy all files from your source to the destination every day at 3 a.m.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fautomated-file-transfer%2F&text=Automate%20File%20Transfers%20with%20PowerShell%20%26%20Scheduled%20Tasks)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fautomated-file-transfer%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fautomated-file-transfer%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2021/08/Icacls-The-Ultimate-Guide.jpg)

### [Icacls: The Ultimate Guide in Managing File Permissions](/icacls/)

Learn how to grant, deny, remove permissions, and more with the icacls command in this ultimate guide!

![](https://adamtheautomator.com/wp-content/uploads/2019/07/file-cannot-accessed-fix-handle-exe-denied.png)

### [Unlock File Locks: Sysinternals Handle & PowerShell](/sysinternals-handle/)

Discover what process has a file locked. Learn to use Sysinternals Handle with PowerShell.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/5d238ae5c824b514689ea638.jpg)

### [Temp File Cleaner: A PowerShell Script Guide](/temp-file-cleaner/)

Reclaim your storage space. Learn to build a custom temp file cleaner with PowerShell.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
