How to Copy files from Windows to Linux using PowerShell Remoting

With the release PowerShell Core 6, the PowerShell Team brought PowerShell to other platforms like 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 systems.

PowerShell Core enables a new feature, PowerShell Remoting Over SSH, SSH remoting lets you do basic PowerShell session remoting between Windows and 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.


This article was originally published by Microsoft's Core Infrastructure and Security Blog. You can find the original article here.