By Ellie / Last Updated December 15, 2023

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

“I have a requirement to use PowerShell to copy a file from the remote machine to the local machine. Can anyone tell me how to do it easily?”

PowerShell: copy file from remote computer to local 

In this part, how to use PowerShell to copy files from remote machine with credentials will be introduced in detail.

Step 1. Run PowerShell as administrator on the local computer.

Windows PowerShell Admin

Step 2. You’ll need to establish a new remote session first. Enter the following command to create a remote session to the remote computer:

$MYSESSION = New-PSSession -ComputerName PC02.TECH.LOCAL

Create Remote Session

Step 3. Verify the properties of the remote session by entering the following command. Then you’ll get the command output as shown in the following picture.

Get-PSSession

Remote Session

Step 4. Copy a file to the remote computer using Powershell with Copy-Item cmdlet. You need to specify the FromSession parameter and a path on the local computer for the Destination parameter. In our example, we copied a text file named “test” from a remote computer using Powershell.

Copy-Item -FromSession $MYSESSION C:\test.txt -Destination C:\test.txt

Note: You’re also able to copy a local file to the remote computer by using ToSession parameter.

Copy-Item -Path "C:\test.txt" -Destination "C:\" -ToSession $MYSESSION

ToSession

Step 5. Type the following command to verify if the file was copied.

Invoke-Command -ScriptBlock { Get-ChildItem -Path "C:\test.txt" } -Session $MYSESSION

Verify Copied Files

Step 6. Here is the command output:

Copies Files Output

Step 7. After finishing, don’t forget to remove the session by using Remove-PSSession.

Remove-PSSession -Session $MYSESSION

Remove Session

Bonus tips: Transfer files between remote devices via AnyViewer [Recommended]

However, you’re not recommended to copy files from a remote computer to a local via PowerShell. There are more reliable and easier methods, using the free and easy remote desktop software AnyViewer is one. It allows you to transfer files freely between two remote devices without effort.

  • Compatibility. It’s compatible with various kinds of Windows systems from Windows 7 to the latest Windows 11.
  • Security. It’s encrypted with Elliptic Curve Cryptography (ECC), which keeps your files safe from prying eyes.
  • Fast speed. It allows you to transfer a batch of files at a really fast speed.

✍Note: The file transfer function requires version 3.0 and above. If your version is lower, please upgrade first.

Download, install and launch AnyViewer on both computers. Then you got two options.

Download Freeware Win 11/10/8.1/8/7
Secure Download

Part 1. Sign up for AnyViewer for file transfer

To use the file transfer feature, you need to sign up for AnyViewer and log in to the account on the Controller computer.

Step 1. On the Controller computer, go to Log in, and then click Sign up. (If you already have signed up on its official website, you can log in directly.)

Log in AnyViewer.png

Step 2. Fill in the signup information.

Sign Up For AnyViewer

Step 3. Then you can see you successfully logged in to AnyViewer. Your device will automatically be assigned to the account you’ve logged in to. 

Free Editions

Part 2. Transfer files with AnyViewer

After signing up for an AnyViewer account and logging in to AnyViewer on the Controller computer, you can start to transfer files. Depending on different situations, you can choose different ways to achieve file transfer.

Option 1. Transfer files without controlling the remote computer

Step 1. Enter the device ID of the recipient on the blank box, and then choose File Transfer.

File Transfer

Step 2. Then you’ll be asked whether to Send a request to your partner or Input security code.

  • Send a request to your partner: The Recipient computer will receive a pop-up window asking whether he/she allows you to control his/her computer.
  • Input security code: You can input the security code set by the Recipient in advance and achieve a direct connection.

Choose a Method

Tips: This option is suitable for users who need to transfer files to a stranger or anyone that you do not completely trust, ensuring security during file transfer.

Option 2. Transfer files during a remote connection session

Step 1. On the Recipient computer, log in to the same account as you’ve logged in to on the Controller computer.

Step 2. On the Controller computer, go to the Device tab, choose your target computer, and click File Transfer to start transferring files.

File Transfer AnyViewer

Tips: This option is suitable for users who need to frequently access their own remote computers and transfer files, ensuring convenience during transfer.

Whatever options you select, a File Transfer dialog box will appear. The path of the Controller computer is shown on the left of the box, and the path of the Recipient computer is shown on the right. You’re able to transfer files between devices (from the Controller computer to the Recipient computer or from the Recipient computer to the Controller computer) freely by clicking the arrows after choosing the target files.

Choose Files

You can see the transfer status at the bottom of the File Transfer dialog box. Right-click to pause or remove the transfer task. The dialog can be closed when the transfer is complete.

Transfer Status

Note: The maximum size of a single file that can be transferred for the free account is 100 MB, and the maximum number of files that can be transferred per time is 100. If you want to transfer larger files in more quantity per time, please upgrade to a Professional or Enterprise plan.

Conclusion

This post primarily introduces how to use PowerShell to copy a file from the remote machine to a local. Also, how to copy a file from the local machine to a remote machine via PowerShell is also introduced. But using PowerShell is always not the recommended method as it is technically demanding. If you need an easy way to copy and paste files between remote devices, give AnyViewer a try.