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.
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 137.117.136.159 -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.