You must have found this guide because you want to know how to copy a file to a remote computer using PowerShell.

Easy file copy scripts on PowerShell

  • PowerShell is a robust Microsoft scripting terminal used to perform multiple operations.

  • You can transfer single and multiple files to remote machines using the proper scripts.

  • Download Restoro PC Repair Tool that comes with Patented Technologies (patent available here).

  • Click Start Scan to find Windows issues that could be causing PC problems.

  • Click Repair All to fix issues affecting your computer’s security and performance

  • Restoro has been downloaded by 0 readers this month.

The good news is that we understand the need for file sharing and have put together every detail you need to know in this article.

So without much ado, let us get to it.

Why should I transfer files using PowerShell?

PowerShell may be used to transfer files for a number of reasons:

  • Speed: When uploading a lot of data across a network, PowerShell may be quicker than utilizing GUI-based solutions.
  • Automation: You may transmit files automatically on a schedule or in reaction to certain circumstances by using PowerShell scripts that have been automated.
  • Versatility: File transfers utilizing FTP, FTPS, SFTP, and SCP are all possible with PowerShell.
  • Handling errors: PowerShell has strong error-handling features that might be helpful when transferring files to make sure the transfer went well.
  • Reporting: PowerShell is capable of generating thorough reports on the transfer procedure, which include the total volume of data transferred, the number of files transferred, and any mistakes that had occurred.

In general, managing file transfers using PowerShell may be practical and effective, especially in a professional setting.

Now here is how to copy files to remote machines using the tool.

How do I copy a file to a remote computer using PowerShell?

1. Copy a file from a remote computer using PowerShell

1.1 Set up the remote connection

  • Open PowerShell with admin rights, input the command below, and hit Enter.Enable-PSRemoting -Force -Verbose
  • If you get the error as displayed in the image above, enter the following command; if not, skip this step:Set-WsManQuickConfig
  • Use the following command to configure your trusted host, substituting AFAM with the name of the computer:winrm set winrm/config/client ‘@{TrustedHosts=“AFAM”}’
  • Use these shell scripts to restart your WinRM service and test the remote computer name after you have added the remote machine name to the trusted host (remember to substitute AFAM for your computer name):Restart-Service WinRM Test-WsMan @AFAM

A few actions to create a remote connection are listed above. One may copy files to distant machines after establishing the remote connection.

  • Why should I transfer files using PowerShell?
  • How do I copy a file to a remote computer using PowerShell?
    1. Copy a file from a remote computer using PowerShell
  • 1.1 Set up the remote connection
  • 1.2 Use Copy-Item to copy the file
    1. Copy multiple files to a remote computer using PowerShell

Some PC issues are hard to tackle, especially when it comes to corrupted repositories or missing Windows files. If you are having troubles fixing an error, your system may be partially broken. We recommend installing Restoro, a tool that will scan your machine and identify what the fault is.Click here to download and start repairing.

Expert tip:

SPONSORED

Note that on a remote system, PowerShell remoting must be enabled. To do this, use the steps highlighted above.

1.2 Use Copy-Item to copy the file

  • Use the New-PSSession cmdlet to start a session using the command below (remember to replace AFAM with the PC name).$SESSION= New-PSSession -Computer ‘AFAM’ -Cred $credential
  • Connect to the newly created session using the command below (note that you can use the cd command to change the directory if needed):Enter-PSSession $SESSION
  • Copy the file using the command below (remember to replace initial and final location with the actual paths you need the file copied from and to):Copy-Item –Path “initial location” –Destination “final location”
  • You may need to quit the shell from the remote machine access after interacting with the remote machine. To do this, you must terminate the session using the Exit-PSSession cmdlet as follows:Exit-PSSession

2. Copy multiple files to a remote computer using PowerShell

  • Follow all the steps mentioned in solution 1.1
  • Declare some variables using the script below (include actual values for the username, password, and both paths):$username = “username”$password = “password”$remote_path = “\remote_computer\c$\path\to\destination”$local_path = “C:\path\to\local\files”
  • Next, create a credential object using the script below:$credential = New-Object System.Management.Automation.PSCredential ($username, (ConvertTo-SecureString $password -AsPlainText -Force))
  • Use the script below to get the local path that has been declared:$files = Get-ChildItem $local_path
  • Finally, copy each file to the remote computer using the foreach function:foreach ($file in $files) {Copy-Item -Path $file.FullName -Destination $remote_path -Credential $credential}

This will copy all the files in the local directory specified by $local_path to the destination directory on the remote computer specified by $remote_path. You will need to provide the correct values for $username, $password, $remote_path, and $local_path.

  • Google Drive is Not Syncing on Windows 11: How to Fix it
  • How to Use ChatGPT in WhatsApp [Step-by-Step Integration]
  • File Count Over Limit in Sharepoint: How to Bypass It
  • Fix: This Email Address is Already Connected with Office 365

There you have it. These are some of the best ways to copy files to a remote computer using MS PowerShell.

PowerShell is a very robust tool, and with some knowledge of scripting, there is a lot you may be able to achieve using the tool. You can copy files from and to remote computers using the tool.

Please let us know in the comments below if this guide has been helpful.

If the advices above haven’t solved your issue, your PC may experience deeper Windows problems. We recommend downloading this PC Repair tool (rated Great on TrustPilot.com) to easily address them. After installation, simply click the Start Scan button and then press on Repair All.

Still having issues? Fix them with this tool:

  • PowerShell

Email *

Commenting as . Not you?

Comment