How to Copy files from Windows to Linux using PowerShell Remoting

Published 06-27-2019 12:00 AM 48K Views

With the release PowerShell Core 6, the PowerShell Team brought PowerShell to other platforms like Linux and macOS. This new cross-platform approach allows users to take advantage of some pretty cool features. In this blog post, I am quickly going to show you, how you can use PowerShell Remoting to copy files from Windows to Linux systems.


PowerShell Core enables a new feature, PowerShell Remoting Over SSH, SSH remoting lets you do basic PowerShell session remoting between Windows and Linux machines.


As you already know from Windows PowerShell Remoting, we can use a PowerShell remoting session to copy files to a remote system, using the Copy-Item cmdlet with the -ToSession parameter.


Copy File Windows to Linux using PowerShell Remoting.jpg



First, you need to make sure that you have installed and configured PowerShell and SSH Remoting. You can find more here: Setup PowerShell SSH Remoting in PowerShell 6


After that you can create a new PowerShell session:


$s = New-PSSession -HostName -UserName Thomas


You can then simply use the Copy-Item cmdlet to copy the file to the specific session:


Copy-Item .\windows.txt /home/thomas -ToSession $s


I hope this gives you a great option to copy files from Windows to Linux using PowerShell Remoting. Thanks to Matjaz Znidar (Microsoft PFE) for the great idea.

1 Comment
Occasional Visitor

This was a great help to me as I tried to create a script for managing the deployment of some .NET Core projects from Windows 10 to a Raspberry Pi 4.  For users of the Pi that follow, I would note that the destination should be /home/pi/XXX (assuming you have established your session as pi).  You need to specify the full path and there may several home directories under /home.


Many thanks

Version history
Last update:
‎Jun 27 2019 04:35 AM
Updated by: