Everyone knows that it is kind of complicated to use PowerShell to copy file from remote computer to local. Lucky you! Here in this post, we provide you with detailed steps on how to do this. Keep reading!
“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?”
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.
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
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
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
Step 5. Type the following command to verify if the file was copied.
Invoke-Command -ScriptBlock { Get-ChildItem -Path "C:\test.txt" } -Session $MYSESSION
Step 6. Here is the command output:
Step 7. After finishing, don’t forget to remove the session by using Remove-PSSession.
Remove-PSSession -Session $MYSESSION
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.
β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.
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.)
Step 2. Fill in the signup information.
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.
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.
Step 2. Then you’ll be asked whether to Send a request to your partner or Input security code.
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.
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.
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.
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.
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.