Home
%3CLINGO-SUB%20id%3D%22lingo-sub-681442%22%20slang%3D%22en-US%22%3EHow%20to%20Copy%20files%20from%20Windows%20to%20Linux%20using%20PowerShell%20Remoting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-681442%22%20slang%3D%22en-US%22%3E%3CP%3EWith%20the%20release%20PowerShell%20Core%206%2C%20the%20PowerShell%20Team%20brought%20PowerShell%20to%20other%20platforms%20like%20Linux%20and%20macOS.%20This%20new%20cross-platform%20approach%20allows%20users%20to%20take%20advantage%20of%20some%20pretty%20cool%20features.%20In%20this%20blog%20post%2C%20I%20am%20quickly%20going%20to%20show%20you%2C%20how%20you%20can%20use%20PowerShell%20Remoting%20to%20copy%20files%20from%20Windows%20to%20Linux%20systems.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPowerShell%20Core%20enables%20a%20new%20feature%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Flearn%2Fremoting%2Fssh-remoting-in-powershell-core%3FWT.mc_id%3Ditopstalk-blog-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPowerShell%20Remoting%20Over%20SSH%3C%2FA%3E%2C%20SSH%20remoting%20lets%20you%20do%20basic%20PowerShell%20session%20remoting%20between%20Windows%20and%20Linux%20machines.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20already%20know%20from%20Windows%20PowerShell%20Remoting%2C%20we%20can%20use%20a%20PowerShell%20remoting%20session%20to%20copy%20files%20to%20a%20remote%20system%2C%20using%20the%20Copy-Item%20cmdlet%20with%20the%20-ToSession%20parameter.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117680i5920D1DE6066444B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Copy%20File%20Windows%20to%20Linux%20using%20PowerShell%20Remoting.jpg%22%20title%3D%22Copy%20File%20Windows%20to%20Linux%20using%20PowerShell%20Remoting.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20you%20need%20to%20make%20sure%20that%20you%20have%20installed%20and%20configured%20PowerShell%20and%20SSH%20Remoting.%20You%20can%20find%20more%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.thomasmaurer.ch%2F2019%2F04%2Fsetup-powershell-ssh-remoting-in-powershell-6%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESetup%20PowerShell%20SSH%20Remoting%20in%20PowerShell%206%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20that%20you%20can%20create%20a%20new%20PowerShell%20session%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%24s%20%3D%20New-PSSession%20-HostName%20137.117.136.159%20-UserName%20Thomas%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20then%20simply%20use%20the%20Copy-Item%20cmdlet%20to%20copy%20the%20file%20to%20the%20specific%20session%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ECopy-Item%20.%5Cwindows.txt%20%2Fhome%2Fthomas%20-ToSession%20%24s%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20gives%20you%20a%20great%20option%20to%20copy%20files%20from%20Windows%20to%20Linux%20using%20PowerShell%20Remoting.%20Thanks%20to%20Matjaz%20Znidar%20(Microsoft%20PFE)%20for%20the%20great%20idea.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-681442%22%20slang%3D%22en-US%22%3E%3CP%3EWith%20the%20release%20PowerShell%20Core%206%2C%20the%20PowerShell%20Team%20brought%20PowerShell%20to%20other%20platforms%20like%20Linux%20and%20macOS.%20In%20this%20blog%20post%2C%20I%20am%20quickly%20going%20to%20show%20you%2C%20how%20you%20can%20use%20PowerShell%20Remoting%20to%20copy%20files%20from%20Windows%20to%20Linux%20systems.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-681442%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

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